PdfPrep.com

Which Transact-SQL query should you use?

You develop a Microsoft SQL Server 2012 database that contains a table named Products.

The Products table has the following definition:

You need to create an audit record only when either the RetailPrice or WholeSalePrice column is updated.

Which Transact-SQL query should you use?
A . CREATE TRIGGER TrgPriceChange ON Products FOR UPDATE AS
IF CCLUMNS_CHANGED(RetailPrice, WholesalePrice)
– – Create Audit Records
B . CREATE TRIGGER TrgPriceChange ON Products FOR UPDATE AS
IF EXISTS(SELECT RetailPrice from inserted) OR
EXISTS (SELECT WholeSalePnce FROM inserted)
– – Create Audit Records
C . CREATE TRIGGER TrgPriceChange ON Products FOR UPDATE AS
IF COLUMNS_UPDATED(RetailPrice, WholesalePrice)
– – Create Audit Records
D . CREATE TRIGGER TrgPriceChange ON Products FOR UPDATE AS
IF UPDATE(RetailPrice) OR UPDATE(WholeSalePrice)
– – Create Audit Records

Answer: D

Explanation:

Reference: http://msdn.microsoft.com/en-us/library/bb510663.aspx

Reference: http://msdn.microsoft.com/en-us/library/ms186329.aspx

Exit mobile version