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
 General SQL Server Forums
 New to SQL Server Programming
 t1 fields exists in t2 then put it in t3

Author  Topic 

gongxia649
So Suave

344 Posts

Posted - 2006-05-10 : 17:14:47

t1
xxx1
xxx2

t2
xxx1
xxx2
xxx3


i like to know how to select t1 xxx1 and xxx2 that exist in t2 and put it in a new t3

nr
SQLTeam MVY

12543 Posts

Posted - 2006-05-10 : 17:19:32
select distinct t1.id
into t3
from t1
join t2
on t1.id = t2.id


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -