Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 delete help

Author  Topic 

neil_akoga
Yak Posting Veteran

56 Posts

Posted - 2010-06-10 : 04:08:51
I have 2 tables, atblBig and atblDistinct

I want to delete all the row in atblBig that DO NOT appear in atblDistinct. I can select them as follows but how would i re-work this to delete these rows.

SELECT atblBig.BigID
FROM [atblBig] AS atblBig
LEFT JOIN [atblDistinct] AS atblDistinct ON atblDistinct.BigID = atblBigt.BigID
WHERE atblDistinct.BigID IS NULL

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-06-10 : 04:15:14
delete atblBig where not exists(select * from atblDistinct where atblDistinct.BigID = atblBigt.BigID)


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

neil_akoga
Yak Posting Veteran

56 Posts

Posted - 2010-06-10 : 04:37:01
cheers fred. much appreciated
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-06-10 : 04:43:46
welcome


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -