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 2008 Forums
 Transact-SQL (2008)
 Delete Syntax help

Author  Topic 

Sonu619
Posting Yak Master

202 Posts

Posted - 2011-03-15 : 21:10:58
Hi guys,

I have two tables,
TABLE1
ID,FNAME,LNAME

TABLE2
ID,ADDRESS,PHONE

Question:- I want to delete ID in Table2 that not in Table1. Thanks in advance.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-03-15 : 21:13:34
[code]
DELETE t2
FROM TABLE2 t2
WHERE NOT EXISTS
(
SELECT *
FROM TABLE1 t1
WHERE t1.ID = t2.ID
)
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Sonu619
Posting Yak Master

202 Posts

Posted - 2011-03-16 : 20:29:07
khtan i appreciate your help.!
Go to Top of Page
   

- Advertisement -