Friday 27 January 2012

Table Diff to identify data mismatch.


1) Run the below query in Publisher.
2) Paste the output in Command Prompt.
3) See the output file for the mismatch.


Declare @sourceserver nvarchar(100) = '<Publisher Server>'
Declare @destinationserver nvarchar(100) = '<Subscriber Server>'

select '"C:\Program Files\Microsoft SQL Server\100\COM\tablediff.exe" -sourceserver [' + @sourceserver +
'] -sourcedatabase [BCP_Tran] -sourcetable [' + name +'] -sourceschema [' + SCHEMA_NAME(schema_id ) +
'] -sourcelocked [TABLOCK] -destinationserver [' + @destinationserver + '] -destinationdatabase [BCP_Tran] -destinationtable [' + name +
'] -destinationschema ['+ SCHEMA_NAME(schema_id )  +'] -destinationlocked [TABLOCK] -f c:\TableDiff_' + name+ '.sql'
      from  sys.tables 
      where type_desc = 'USER_TABLE' and is_published=1
      

No comments:

Post a Comment