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 statement with a join condition

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2010-03-25 : 11:17:13
I want to delete rows in table tab_EmailDownloadMaster if the emaildownloadid is not in table tab_EmailFilesInfo

delete from tab_EmailDownloadMaster where if emaildownloadid is not in this tab_EmailFilesInfo.

join tab_EmailDownloadMaster.emaildownloadid = tab_EmailFilesInfo.emaildownloadid

Thank you very much for the helpful info.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-25 : 11:20:38
[code]delete from tab_EmailDownloadMaster where not exists (select 1 from tab_EmailFilesInfo where emaildownloadid= tab_EmailDownloadMaster.emaildownloadid )[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

msuneerbabu
Starting Member

6 Posts

Posted - 2010-03-25 : 11:23:39
try this,

delete from tab_EmailDownloadMaster where emaildownloadid not in (Select emaildownloadid from tab_EmailFilesInfo)
Go to Top of Page
   

- Advertisement -