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 2000 Forums
 Transact-SQL (2000)
 combine two tables

Author  Topic 

kakalaky
Starting Member

1 Post

Posted - 2008-02-26 : 21:44:07
I have two tables with several columns that match but each also has columns that do not match. I need to combine the tables so that the parts that match are in the same columns but the columns that don't match are still there. They can be filled with NULL where no data is available. Anybody know how to achieve this? Thanks.

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-02-26 : 22:19:25
Do you have table schema? Have dup data in those tables?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-27 : 00:14:25
[code]SELECT ISNULL(t1.MatchCol1,t2.MatchCol1),
ISNUll(t1.MatchCol2,t2.MatchCol2),
.........,
t1.UnmatchCol1,t2.UnmatchCol1,
t1.UnmatchCol2,t2.UnmatchCol2,.....
FROM Table1 t1
LEFT JOIN Table2 t2
ON t1.MatchCol1=t2.MatchCol1
AND t1.MatchCol2=t2.MatchCol2
AND...[/code]
Go to Top of Page
   

- Advertisement -