Options

how to ignore the primaryKey fields while comparision

srikmrsrikmr Posts: 16
Hi,
This query might look weird.
Here is my case;
i have a table Table1 in DataBase1. It has a primarykey column and couple of other columns. The primary key column is auto generated and the other columns are populated with my data.

I have the same table Table1 in Database2. The contents of all the columns are same EXCEPT the primarykey column as this gets auto generated.

I am trying to Compare the Data in the two tables using where clause of one of my colums.
COMPARE DATA IN TABLE1 in DB1 where NAME = 'ABC' With the Data in Table1 in DB2 where Name = 'ABC'
(but Name is not a Primary key for the tables).

But i have no control over the primarykey column which is auto generated.
I am not able to ignore this primary key column while comparing.
Is there a way to ignore the primarykey column for comparision. (both in the UI and as well in the ToolKit).
Appreciate your help.
Regards
Sri

Comments

  • Options
    Hi Srikmr

    It is possible to change the comparison key used when comparing tables in the Data Compare UI.
    Click Edit Project to get the Project Configuration dialog - in the Tables & Views tab notice that the Comparison Key column on the left has a drop-down that allows you to select a custom comparison key. The column you select here should then be used by data compare to match the rows between two tables without the need for a WHERE clause. I hope that this helps.

    I'll have to get back to you regarding the best method for doing this with the API. I presume that you are familiar with the SQLToolkit.chm file that we ship with the product?

    Best Regards
    Chris
    Chris Spencer
    Test Engineer
    Red Gate
  • Options
    Hi Srikmr

    In addition to the SQLToolkit.chm help file we ship some very useful code samples. If you've installed to the default location then they should be at:

    C:\Program Files\Red Gate\SQL Bundle 5\Toolkit Sample Files\Automating SQL Data Compare

    The samples are provided in C# and VB.NET. I suspect that the code in TableMappingExample.cs will be of most help to you.

    Best Regards
    Chris
    Chris Spencer
    Test Engineer
    Red Gate
Sign In or Register to comment.