April 8, 1998
While cleaning up data you may create orphan records (before you have created FK constraints). This script purges orphan records from a child table. It takes the arguments of parent_table, child_table and linking_field and then finds all the child records with no parent record and deletes them.
For SQL Server 6.5
Author: Tom De Lancey
Disclaimer: We hope that the information on these script pages is
valuable to you. Your use of the information contained in these pages,
however, is at your sole risk. All information on these pages is provided
"as -is", without any warranty, whether express or implied, of its accuracy,
completeness, or fitness for a particular purpose...
Back to Database Journal Home