• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 186
  • Last Modified:

sql Delete

I have two tables Master,Detail related on Master.sLink and detail.slink. I need to delete rows in master that do NOT appear in Detail.

Ive been messing with this all morning and need some guidence.
0
stephenz43
Asked:
stephenz43
2 Solutions
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
delete master
where not exists ( select null from detail where detail.slink = master.slink )
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
delete from [Master] m
WHERE NOT EXISTS (SELECT 1 from Detail where sLink = m.slink)

or


DELETE FROM [Master]
WHERE sLink NOT IN (SELECT slink FROM Details)
0
 
stephenz43Author Commented:
thank you
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now