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
 Development Tools
 Other Development Tools
 Remove non existing clients in T1 based on T2

Author  Topic 

iboumiza
Starting Member

9 Posts

Posted - 2011-08-16 : 09:26:48
Hi,

what I need to do is:

1- Table 1 is old and contains some no longer existing clients name

2- Table 2 is new and do not contain non existing clients names


How do I design the query in a way the code look in table 2 and remove from table 1 the no longer existing clients, please ?

Thanks

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-08-17 : 02:19:58
delete t1
from table1 as t1
left join table2 as t2 on t1.id = t2.id
where t2.id is null


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

- Advertisement -