Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Delete orphan records SQL Server 2008 R2

$
0
0

I have a situation where there is a routing file and an instruction file.  There is a one to many relationship between them. the two files I'll are related by an item_no and a seq_no.

A programmer deleted certain records out of the routing file without first checking and deleting the related routing instructions first.  

Can anyone offer a snippet of code that would help me identify and delete the orphan records in the instruction file? 

I have done deletes to a file based on the related record being "in" a subquery result, but what is throwing me is the two-key relationship between the files. 

Thanks,

Paul


Viewing all articles
Browse latest Browse all 4871


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>