Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to compare 2 Table Data
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

micnie_2020
Posting Yak Master

Malaysia
232 Posts

Posted - 03/20/2013 :  03:36:32  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

India
2242 Posts

Posted - 03/20/2013 :  03:38:20  Show Profile  Reply with Quote

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

--
Chandu

Edited by - bandi on 03/20/2013 04:22:30
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000