Friday, February 10, 2012

Comparing two tables

Hi,
I have two identical tables in a database, the only difference between
to two is the data that is in each table. Is there a way of comparing
the two tables together in a query and listing the differences that are
in table one? I have been trying to do this with joins but without much
success.
Any help would be much appreciated.
Thanks
SimonLook up OUTER JOIN in Books Online.
For a more accurate solution, please post DDL, sample data and expected
results.
ML
http://milambda.blogspot.com/|||Take a look at this
http://sqlservercode.blogspot.com/2...-price-tag.html
you basically join on the key field and do a BINARY_CHECKSUM
Denis the SQL Menace
http://sqlservercode.blogspot.com/
accyboy1981 wrote:
> Hi,
> I have two identical tables in a database, the only difference between
> to two is the data that is in each table. Is there a way of comparing
> the two tables together in a query and listing the differences that are
> in table one? I have been trying to do this with joins but without much
> success.
> Any help would be much appreciated.
> Thanks
> Simon|||accyboy1981 wrote:

> Hi,
> I have two identical tables in a database, the only difference between
> to two is the data that is in each table. Is there a way of comparing
> the two tables together in a query and listing the differences that are
> in table one? I have been trying to do this with joins but without much
> success.
> Any help would be much appreciated.
> Thanks
> Simon
SQL Server 2005 has new utiltity tablediff which you can find at
C:\Program Files\Microsoft SQL Server\90\COM>
It is used in replication to find change data between tables on
publisher and subscribter , but we can also use it if we want to
compare tables with data.
Also look at except operator in SQL Server 2005
Regards
Amish shah

No comments:

Post a Comment