Which trigger syntax should you use?

You are developing a database using Microsoft SQL Server 2008. The database contains the tables shown in the following exhibit. (Click the Exhibit button.)
You are required to prevent parts from being deleted if they belong to a kit. If a part belongs to a kit, the delete should not occur and the IsDeleted column for the row should be changed to ‘True’. Parts should be deleted if they do not belong to a kit. You have the following Transact-SQL statement to be used in a trigger:
UPDATE p
SET IsDeleted = 1
FROM KitPart kp
JOIN deleted d ON kp.PartID = d.PartID
JOIN Part p ON kp.PartID = p.PartID;
DELETE FROM p
FROM Part p
JOIN deleted d ON p.PartID = d.PartID
LEFT OUTER JOIN KitPart kp ON p.PartID = kp.PartID
WHERE kp.KitID IS NULL;
You need to implement the Transact-SQL statement in a trigger. Which trigger syntax should you use?
Exhibit:


A. CREATE TRIGGER tr_Part_d ON Part INSTEAD OF DELETE AS BEGIN …END
B. CREATE TRIGGER tr_Part_d ON Part AFTER DELETE AS BEGIN …END
C. CREATE TRIGGER tr_KitPart_d ON KitPart AFTER DELETE AS BEGIN …END
D. CREATE TRIGGER tr_KitPart_d ON KitPart INSTEAD OF DELETE AS BEGIN …END

microsoft-exams

Leave a Reply

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


The reCAPTCHA verification period has expired. Please reload the page.