Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Referential Integrity

Author  Topic 

S.Djaoen
Starting Member

1 Post

Posted - 2010-03-03 : 08:18:10
Hi

I've several tables that are linked to each other by foreign key.
I want to delete the data in those tables with one delete statement where i can include all the tablesname that I want to delete data from.

Do I need to use Check || No Check or something else?

please help

DaleTurley
Yak Posting Veteran

76 Posts

Posted - 2010-03-03 : 08:34:53
You would have to use several deletes, deleting from the referencing down to the referenced.

Another option, although not a great one, is to use cascaded deletes. You delete the referenced row and all referencing rows are then deleted.

I've used this with reports before. So if a report is deleted, the data to be included in the report is deleted aswell.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-03 : 09:13:23
I would prefer manual deletion to cascade deletes as you wont get track of what all tables data get deleted when you're using cascading delete option and especially when there are lots of tables related by fk as in case above

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -