January 3, 2007 at 4:40 pm
Hello All
Happy new year.. i am currently working on a fixing a production database. The entire database has no referential integrity . I am in the process of putting in the FK constraints. But there seems to be a lot of orphan records in detail tables. I could go one by one to find unmatched records and delete them and then apply the constraints.. Is there any faster way to check the orphan records and delete them . I bet there should be some script or an app out there to check so and delete these orphan records
Any help will be greatly appreciated
Thanks in advance
Gaja
January 3, 2007 at 5:43 pm
You can create FK without deleting using NOCHECK option and then you can write a cleanup script using not exists command.
You can make use of the script from the following url..
http://www.sqlservercentral.com/scripts/viewscript.asp?scriptid=224
MohammedU
Microsoft SQL Server MVP
January 4, 2007 at 5:34 pm
Hey Mohammed
Thank you very much for the pointer.. that helped me a lot .. i did not know there was a script library in here.. lots of cool stuff
Thanks again
Gaja
January 4, 2007 at 5:34 pm
Hey Mohammed
Thank you very much for the pointer.. that helped me a lot .. i did not know there was a script library in here.. lots of cool stuff
Thanks again
Gaja
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply