hello guys!
Well im using MS SQL 2000 and i have over 250 Tables in one of my Database the problem is all the Foreign Key in the Table is not turn ON in ON DELETE CASCADE.
The question is, is there anyway to write a script to turn the ON DELETE CASCADE on all the Tables?
Thanks for the reply!
Novelle
Nope, not really. You will just have to script your keys out, then change to ON DELETE CASCADE manually. Unless there is some tool to do it, but I don't know of it.
A trick I would use is to take your database scripts (or if you don't have any, use a comparison tool, compare my full database to an empty one) and just replace all ON DELETE NO ACTION values with ON DELETE CASCADE. Then use your script to build a database that matched your database, except for the CASCADE constraints.
Then just do the comparison again, and let the tool do the work. (I use RedGate personally, but there are others)
sql
No comments:
Post a Comment