TableDiff.exe - SQL Server Comparision Utility

The tablediff.exe is very useful command line utility to compaire two tables from SQL Server instances.

tablediff.exe utility features

  • Comparison between two tables from SQL Server instance. 
  • Row by row fast comparision. 
  • Perform column level comparion. 
  • Easily generate change script between production and development SQL server instances.
  • Log result can be captured as output file or database table.

Location:

tablediff.exe is available on SQL Server instance at
"<DriveLetter>:\Program Files\Microsoft SQL Server\90\COM\TableDiff.exe"

 <DriveLetter> is the hard drive where SQL Server instance is installed.

Example:

Following example compaires two tables from same database on same server and create the diference in table "ChangeScript"

"C:\Program Files\Microsoft SQL Server\90\COM\tablediff.exe" -sourceserver SQLServerInstanceName
                                                                                        -sourcedatabase SQLServerDatabaseName
                                                                                        -sourcetable Table1
                                                                                        -destinationserver SQLServerInstanceName 
                                                                                        -destinationdatabase SQLServerDatabaseName
                                                                                        -destinationtable Table2
                                                                                        -et ChangeScript

You can also compaire two tables from two different databases which are hosted on two different server by  changing above mentioned attributes. Also You can generate t-sql change script as well instead of ChangeScript table. Following example will generate t-sql change script.

"C:\Program Files\Microsoft SQL Server\90\COM\tablediff.exe" -sourceserver SQLServerInstanceName
                                                                                        -sourcedatabase SQLServerDatabaseName
                                                                                        -sourcetable Table1
                                                                                        -destinationserver SQLServerInstanceName 
                                                                                        -destinationdatabase SQLServerDatabaseName
                                                                                        -destinationtable Table2
                                                                                        -et ChangeScript
                                                                                        -f C:\Temp\ChangeScript.sql

More information and more switches for tablediff utility can be found here

Category

Recent Posts

Tag cloud