Skip to main content

tablediff command line utility in SQL Server

Above tablediff utility is very useful for comparing tables.It is not only tells us which records / columns are different but can also generate a SQL script to update the second table to make it the same as the first table.

You have to navigate to following path the use this utility

SELECT 'C:\Program Files\Microsoft SQL Server\100\COM>

Then type command ;

tablediff –?

Then it shows all the options as follows
 tablediff

But only limitation is you could compare one table at a time. Even though you can do some interesting work to overcome this. That is Just go to the SQL sever and type following command execute it. So it will generate the script for all the table. Then you can add it into .bat file.

SELECT 'C:\Program Files\Microsoft SQL Server\100\COM>tablediff -sourceserver "SourceDBName" -sourcedatabase "T1" -sourcetable ' + '"' + name +'" ' + '-destinationserver "DestinationDBName" -destinationdatabase "T2" -destinationtable ' + '"' + name +'" ' + ' -o d:\' + name +'_Script_out.txt'
FROM dbo.sysobjects
WHERE xtype = 'U'

Comments

Popular posts from this blog

The transaction is in doubt

Sometimes you may get this error when you use transaction scope . The transaction is in doubt I also got this error recently and able to find the reason for it. That is because of the some of the readers had not properly disposed. Actually in this case you can use Using keyword to overcome this. Exception : System.Transactions.TransactionInDoubtException was unhandled by user code Message="The transaction is in doubt." Solution : using (reader) { }

MySQL Stored Procedure Error

In our project we had many many stored procedures and many parameters passes to those sps. But in only one sp it gives error message something like this; "Incorrect number of arguments for PROCEDURE sproc_t_l_Contract_Select_BySearchCriteria; expected 3, got 2” Work long time on this sp but coudnt find it. So i tried to write it again from the begining. In this time it was work perfectly.This problem occurs because of the space between data type and its length. Ex. pName varchar(50) - working pName varchar (50) - Not working But it does not mention syntax error or something.So this error message make us vulnerable.