Retrieving only the source and data mismatch with the tablediff utility

I use the tablediff utility to transfer data from the server database sources to the target database, and I get a result that has all the differences between the source and target databases with something like this

 Dest. Only N'1027' N'799' N'91443' N'1' Mismatch N'103A' N'799' N'13010' N'1' DATE_CURRENT DATE_OPERATION MATRICULE_UTILISATEUR QTE QTE_FINAL QTE_INIT QTE_OPERATION REFERENCE_DOCUMENT TYPE_DOCUMENT Src. Only N'103A' N'310' N'30129' N'1' 

therefore, the generated sql file contains delete line Dest. Only Dest. Only , update string Mismatch and insert string Src. Only Src. Only

My question is: is there a way to use tablediff to get the result of only Mismatch and Src. Only Src. Only rows ??

+8
comparison sql-server data-synchronization
source share
2 answers

At the end of your tablediff command tablediff add the following

 -dt -et DiffResults 

An existing table opens with the name DiffResults and creates a new one on the target server and database. You can then query the DiffResults table to get the rows you need. In my test, I run the following

 SELECT * FROM DiffResults WHERE MSdifftool_ErrorDescription in ('Mismatch','Src. Only') 

or

 SELECT * FROM DiffResults WHERE MSdifftool_ErrorCode in (0,2) -- 0 is for 'Mismatch'; 1 is for 'Dest. Only' and 2 is for 'Src. Only' 

Here you can find more information - https://technet.microsoft.com/en-us/library/ms162843.aspx

+4
source share

If you want to use the results from the command line, you can print the output using findstr:

 tablediff <your parameters> | findstr /i "^Mismatch ^Src" 
0
source share

All Articles