May 21, 2014 at 10:19 pm
How to delete rows in multiple tables with foreign constraints at a time in singe query..?
I have 4 tables namely Users,User_Organization,User_Status_Role,and User_Organization_Role.
Users table have user_id as Primary Key.remaining tables have foreign Key Dependences.
How to delete rows in Primary key and foreign key rows in all tables at a time...
May 22, 2014 at 4:42 am
For that you need to use ON DELETE CASCADE
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
May 22, 2014 at 7:51 am
Just remember that ON DELETE CASCADE also allows mistaken manual deletes to spread the mistake to 4 other tables, as well. 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply