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
 compare two similar tables

Author  Topic 

learn2do
Starting Member

2 Posts

Posted - 2011-10-16 : 18:55:25
I have two similar tables(a,b) with 40 (same) columns. I want to compare data of each column in a with respective column in table b and report only the columns that are mismatching.
Does anybody has a procedure/query to achieve this?

Thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-10-16 : 23:20:31
Here you go: http://weblogs.sqlteam.com/jeffs/archive/2004/11/10/2737.aspx

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

jassi.singh
Posting Yak Master

122 Posts

Posted - 2011-10-17 : 01:31:01
Hi,
Refer:http://www.dba-oracle.com/t_convert_set_to_join_sql_parameter.htm
http://www.sql-server-tool.com/compare-two-tables.htm
http://msdn.microsoft.com/en-us/library/ms188055.aspx

You can use union all or except or merge but depending on need
union all: will give you is there any difference
except: will show you the column which differ
merge: can act on difference i.e. update,delete,insert statements

Please mark answer as accepted if it helped you.

Thanks,
Jassi Singh
Go to Top of Page

learn2do
Starting Member

2 Posts

Posted - 2011-10-17 : 08:21:19
Hi,

I don't wanna see matching columns in the output.
How do I hide them ?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-17 : 08:29:16
if you use jeffs suggestion you will get only unmatched columnlist

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -