Insert and delete of same row

Compares and synchronizes SQL database content.

Insert and delete of same row

Postby miljan » Sun Feb 12, 2012 9:00 am


I'm facing one strange situation using SQL Data Compare 9. When I do the comparison of two tables with same structure, application shows the same row to be deleted and inserted (it can be found in both "Rows only in DB1" and "Rows only in DB2".
I've checked the tables, they are compared by primary key that is the same in both tables. Also, in DB2 the row that is marked for deletion does not exist, but it is anyway marked for deletion.
I assume that application does this in order to be sure that the row that is to be inserted isn't added to table in meantime so the script wouldn't report the error when it is executed, but this is not very suitable for my case when I get a couple of millions of rows with differences...
Is there some option or something that would tell the application not to add the rows that are to be inserted to the deletion list?

Also, I've noticed that some rows are added to both sides although they exist in both tables with identical data. Why is this happening?


Posts: 1
Joined: Sun Feb 12, 2012 8:29 am

Postby Brian Donahue » Mon Feb 13, 2012 3:31 pm

Yes, that is very likely, since updates are batched into inserts and deletes. This is why Data Compare has the "disable primary keys" option to work around that.

Rows that can be matched by key ID should not be inserted or deleted. Typically this happens when you set a text field as the primary key and the collation differs, or on one side you have a variable-length column and a fixed-length column on the other. As a workaround, you can try the "Force binary collation" and "Trim trailing spaces" options, respectively.
Brian Donahue
Posts: 6590
Joined: Mon Aug 23, 2004 9:48 am

Return to SQL Data Compare Previous Versions

Who is online

Users browsing this forum: No registered users and 0 guests