Which Transact-SQL query should you use?

Your database contains tables named Products and ProductsPriceLog. The Products table contains
columns named ProductCode and Price. The ProductsPriceLog table contains columns named
ProductCode, OldPrice, and NewPrice. The ProductsPriceLog table stores the previous price in the
OldPrice column and the new price in the NewPrice column.

You need to increase the values in the Price column of all products in the Products table by 5
percent.
You also need to log the changes to the ProductsPriceLog table.
Which Transact-SQL query should you use?

Your database contains tables named Products and ProductsPriceLog. The Products table contains
columns named ProductCode and Price. The ProductsPriceLog table contains columns named
ProductCode, OldPrice, and NewPrice. The ProductsPriceLog table stores the previous price in the
OldPrice column and the new price in the NewPrice column.

You need to increase the values in the Price column of all products in the Products table by 5
percent.
You also need to log the changes to the ProductsPriceLog table.
Which Transact-SQL query should you use?

A.
UPDATE Products SET Price = Price * 1.05
OUTPUT inserted.ProductCode, deleted.Price, inserted.Price
INTO ProductsPriceLog(ProductCode, OldPrice, NewPrice)

B.
UPDATE Products SET Price = Price * 1.05
OUTPUT inserted.ProductCode, inserted.Price, deleted.Price
INTO ProductsPriceLog(ProductCode, OldPrice, NewPrice)

C.
UPDATE Products SET Price = Price * 1.05
OUTPUT inserted.ProductCode, deleted.Price, inserted.Price *
INTO ProductsPriceLog(ProductCode, OldPrice, NewPrice)

D.
UPDATE Products SET Price = Price * 1.05
INSERT INTO ProductsPriceLog (ProductCode, CldPnce, NewPrice;
SELECT ProductCode, Price, Price * 1.05 FROM Products

Explanation:
http://msdn.microsoft.com/en-us/library/ms177564.aspx



Leave a Reply 4

Your email address will not be published. Required fields are marked *


Zweeble

Zweeble

What’s the difference between A and C?
Just the “*” which Looks like a typing error?

Hai Dang

Hai Dang

My Opinion C is wrong because step running
1: UPDATE Products SET Price = Price * 1.05
2: INSERT INTO ProductsPriceLog (ProductCode, CldPnce, NewPrice;
3: SELECT ProductCode, Price, Price * 1.05 FROM Products
if step 3 run then Log newPrice is wrong Double *1.05

Ricardo

Ricardo

C have a error inserted.Price *(error)

Hina Khawar

Hina Khawar

not for 462 exam, this one for ETL 461