Home
> SQL and .NET Blog > How to compare two tables in SQL server
How to compare two tables in SQL server
SQL Server is having a command line tool (TableDiff) to compare the data in two tables.It will perform the following task.
- A row by row comparison between a source table in an instance of Microsoft SQL Server acting as a replication Publisher and the destination table at one or more instances of SQL Server acting as replication Subscribers.
- Perform a fast comparison by only comparing row counts and schema.
- Perform column-level comparisons.
- Generate a Transact-SQL script to fix discrepancies at the destination server to bring the source and destination tables into convergence.
- Log results to an output file or into a table in the destination database.
eg:
"C:\Program Files\Microsoft SQL Server\90\COM\TableDiff.exe" -sourceserver "SERVERNAME" -sourcedatabase "DBNAME" -sourceschema "dbo" -sourcetable "SOURCETABLE1" -sourceuser "sa" -sourcepassword "PASSWORD" -destinationserver "SERVERNAME" -destinationdatabase "DBNAME" -destinationschema "dbo" -destinationtable "SOURCETABLE2" -destinationuser "sa" -destinationpassword "PASSWORD" -dt -o "C:\Documents and Settings\renjuraj\My Documents\diff.xls"
Run the above command in command prompt.Please refer your sql server installation path(C:\Program Files\Microsoft SQL Server\90\COM\TableDiff.exe).
-Yuva
Categories: SQL and .NET Blog
Comments (0)
Trackbacks (0)
Leave a comment
Trackback