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.
| Author |
Topic |
|
ConnieXujuan
Starting Member
48 Posts |
Posted - 2011-12-29 : 17:12:10
|
Hi -,I have two tables here: t1 and t2. The two tables have some rows that are overlapped. If I want to select the overlapped part into a new table how should my query be like? I could not use the below query as it would have duplicated rows and give me error message:select*into NewTablefrom t1, t2where t1.ID=t2.IDso how can I do a query to achieve it?Thanks a lot!Connie  |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-12-29 : 18:11:11
|
| select distinct *into newtablefrom t1instersectselect distinct *from t2This gives you where every column in t1 is equal to every column in t2JimEveryday I learn something that somebody else already knew |
 |
|
|
ConnieXujuan
Starting Member
48 Posts |
Posted - 2011-12-29 : 19:34:17
|
| Thanks a lot Jim! |
 |
|
|
|
|
|