I have do delete some SQL Server 2008R2 tables that are related with foreign keys, is there any way to select the tables I need in the right order so I'll not receive any error of child records because I'm not deleting the data according to the FK? Thank you.
Asked
Active
Viewed 256 times
0
-
I've been using this script http://stackoverflow.com/a/14995032/284111 perhaps not exactly what you need, but you probably can modify it. – Andrew Savinykh Feb 03 '14 at 21:56
1 Answers
0
Did you check the FOREIGN KEY
Definitions to see if they have CASCADE DELETE
turned on? If yes, then SQL Server will automatically CASCADE the DELETEs on related Child records.

Shiva
- 20,575
- 14
- 82
- 112
-
we don't have cascade delete turned on so I need to delete them from bottom to top. Thanks! – rgx71 Feb 03 '14 at 22:17