What should you do?

You have a database that contains two tables named Table1 and Table1_Details. Table1_Details contains details about items in Table1. You need to ensure that when an item is removed from Table1, all related items are removed from Table1_Details. You must achieve this goal by using the minimum amount of Transact-SQL code. What should you do?

You have a database that contains two tables named Table1 and Table1_Details. Table1_Details contains details about items in Table1. You need to ensure that when an item is removed from Table1, all related items are removed from Table1_Details. You must achieve this goal by using the minimum amount of Transact-SQL code. What should you do?

A.
Create a foreign key relationship. Set Cascade Delete to Null.

B.
Create a foreign key relationship. Set Cascade Delete to True.

C.
Create a trigger on Table1_Details that fires on the Delete action.

D.
Create a stored procedure that deletes all related items from Table1_Details.

Explanation:
ON DELETE CASCADE
Specifies that if an attempt is made to delete a row with a key referenced by foreign keys in existing rows in other tables, all rows containing those foreign keys are also deleted. If cascading referential actions have also been defined on the target tables, the specified cascading actions are also taken for the rows deleted from those tables.



Leave a Reply 0

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