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)
 How to compare 2 Table Data

Author  Topic 

micnie_2020
Posting Yak Master

232 Posts

Posted - 2013-03-20 : 03:36:32
Hi All,

I have 2 Table; 1 is old & 1 is new:

Old
ID cos vendor
1 100 ABV
2 200 AGV

New
ID cos vendor
1 200 YBV
3 900 LGV


Output i want is:

ID cos vendor
Old New Old New
1 100 200 ABV YBV
2 200 - AGV -
3 - 900 - LGV



Please advise.

Thank you.

Regards,
Micheale

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-03-20 : 03:38:20
[code]
SELECT COALESCE(o.ID, n.ID) ID, o.cost OldCost
,n.cost NewCost, o.vendor OldVendor, n.vendor OldVendor
FROM Old o
FULL OUTER JOIN new n ON o.Id= n.ID
[/code]
--
Chandu
Go to Top of Page
   

- Advertisement -