PrepAway - Latest Free Exam Questions & Answers

Which Transact-SQL query should you use?

You develop a Microsoft SQL Server 2012 database that contains a table named
Customers. The Customers table has the following definition:

You need to create an audit record only when either the MobileNumber or HomeNumber
column is updated.
Which Transact-SQL query should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
CREATE TRIGGER TrgPhoneNumberChange
ON Customers FOR UPDATE
AS
IF COLUMNS_UPDATED (HomeNumber, MobileNumber)
– – Create Audit Records

B.
CREATE TRIGGER TrgPhoneNumberChange
ON Customers FOR UPDATE
AS
IF EXISTS( SELECT HomeNumber FROM inserted) OR
EXISTS (SELECT MobileNumber FROM inserted)
– – Create Audit Records

C.
CREATE TRIGGER TrgPhoneNumberChange
ON Customers FOR UPDATE
AS
IF COLUMNS_CHANGED (HomeNumber, MobileNumber)
– – Create Audit Records

D.
CREATE TRIGGER TrgPhoneNumberChange
ON Customers FOR UPDATE
AS
IF UPDATE (HomeNumber) OR UPDATE (MobileNumber)
– – Create Audit Records

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

One Comment on “Which Transact-SQL query should you use?

  1. Minion says:

    The condition in A & C is AND.

    IF EXISTS in B will always return true because even if you update one of the two column or not, if the they have an existing value (NOT NULL).

    That’s why D is the correct answer.




    0



    0

Leave a Reply