On using Tablediff.exe utility in SQL Server

  • Hello,

    I am trying to compare two tables (TableA and TableB) with TableDiff.exe, the two tables have different schema.

    To get away with this different schema issue, I created views ViewA and ViewB on TableA and TableB respectively, that both Views ViewA and ViewB are exactly same schema.

    Column Names, Datatypes , Datatype length are same for both.

    Even now I am getting the same Error ??

    have different schemas and cannot be compared.

    Is there any other work around for this ?

    Thanks in Advance.

  • why not change the schema of the table to the one which you want.

    If your table T1 is bound with schema S1 and table T2 with S2, then even after creating the view the objects are still in those table and bounded to the same schema.

    Views is nothing but virtual table.

    ----------
    Ashish

  • I have done this using powershell and you can also use this :

    $ss = "souce_server" ;

    $sd = "source_database" ;

    $st = "source_table" ;

    $ds = "destination_server" ;

    $dd = "destination_database" ;

    $dt = "destination_table" ;

    $tablediff_directory = "C:\Program Files\Microsoft SQL Server\130\COM\" ;

    $op = "D:\test.sql" ;

    CD $tablediff_directory

    tablediff.exe -f $op -sourceserver $ss -sourcedatabase $sd -sourcetable $st -destinationserver $ds -destinationdatabase $dd -destinationtable $dt

  • I thought there were settings for source and destination schema.  It defaults to dbo, but afaik, the two schemas do not have to be the same.

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.

  • yes, there is an option for schema selection on both side

    $ssc = "source_schema"

    $dsc = "destination_schema"

    you can append this option on above command

    -sourceschema $ssc -destinationschema $dsc

     

    the full doc is available on : https://docs.microsoft.com/en-us/sql/tools/tablediff-utility?view=sql-server-2017

     

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply