SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Delete the Child Records without a Parent
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

StacyOW
Yak Posting Veteran

USA
87 Posts

Posted - 10/12/2013 :  12:13:55  Show Profile  Reply with Quote
I am importing data from a paradox table and trying to clean it up. I have this query that finds all the child records that are not in the parent table.
Select MemberID 
 FROM memtype AS a
 WHERE NOT EXISTS
 (SELECT *
 FROM members AS b
 WHERE a.MemberID IN (b.MemberID));


Now I'm trying to delete all those child records instead of just selecting them so I tried...
Delete MemberID 
 FROM memtype AS a
 WHERE NOT EXISTS
 (SELECT *
 FROM members AS b
 WHERE a.MemberID IN (b.MemberID));


Sql clearly doesn't like this. What am I doing wrong?

Thanks,
Stacy

madhivanan
Premature Yak Congratulator

India
22755 Posts

Posted - 10/12/2013 :  12:37:44  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
Delete a
FROM memtype AS a
WHERE NOT EXISTS
(SELECT *
FROM members AS b
WHERE a.MemberID IN (b.MemberID));

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000