Link to home
Start Free TrialLog in
Avatar of Roger Alcindor
Roger Alcindor

asked on

autoincrement identity problem with merge replication sql server 2005

I have a system that comprises two MS Sql server database servers with merge replication configured.
The publisher publishes a table that has a primary key of type integer that is an identity columne with a seed of 1 and an increment of 1.
All data updates are performed at the subscriber under normal circumstances.
Periodic archiving results in the deletion of records from the publisher and the replication functions as expected, resulting in the same deletions at the subscriber database.
An incident occurred which required taking the publisher off line and continueing with the subscriber database for a short period. primary key did not continue with the expected values that would follow on (autoincremented) from the records in the publisher database. Instead, the values continued from a lower value as if the system was attempting to fill in the numbers that had been previously deleted.
This poses a problem due to the loss of referential integrity.
Goe can i configure the publisher/subscriber so that the auto-incremented columne in the table continues contigiously regardless.

Thanks,

Roger
when new records were added to the subscriber tale however, it was observed that the
Avatar of Raja Jegan R
Raja Jegan R
Flag of India image

I have read about this problem somewhere.

And to resolve this problem its expected to have Identity(1,2) in your First Server and Identity(2,2) in your second server so that this would be unique and you will not face referential integrity issues.

Will check for that article or reference and provide you the reference soon.
when in replication, the only "secure" primary key method is the use of uniqueidentifiers. they are globally unique
will require some application changes, though :/(
alcindor,
    I found the document reference and it was from a third party application involved in Replication methodologies and I cannot share their proprietary document here.

Whatever I mentioned above applies and you have to make it as Identity(1,2) in first server and Identity(2,2) in second server to handle out this issue.
Avatar of Roger Alcindor
Roger Alcindor

ASKER

Thanks for your reply guys.
I was already aware of the your suggestion (1,2) and (2,2) but in this case it is not a practical option at this stage.
In this instance, the subscriber database is acting purely as a backup device that can be switched to if an emergency arises which requires the publisher to go off line. The subscriber then functions temporarily until the publisher can be placed back on line.
At any one time, the system is either writing data to the publisher or (after the publisher has been taken off line) the system is writing data to the subscriber. At no time whist both publisher and subscriber are on line does data get written to both servers.
When the publisher is taken off line, the subscriber is up to date with the most recent identity that was generated by the publisher. the problem is that even though the most recent identity in the subscriber matches that of the publisher, when the next record is generated by the subscriber it generates an identity that is not the incremented value of the current highest identity but some value considerable lower.
There must be a value stored in the subscibers configuration somewhere that the system uses to calculate the next identity? If I knew where this was then I could conceivably set it to the required value and the subscriber would function as required? I am not in a position to adopt the suggestion that you recommend at the moment, I seek the information mentioned above; namely "where is the information kept that determines the next value of the Identity for any particular table such that I can change it?

Thanks in anticipation,

Roger

 
ASKER CERTIFIED SOLUTION
Avatar of Raja Jegan R
Raja Jegan R
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Excellent!
That is exactly what I needed to know, I( will not be able to implement it for a few days but I'm confident that I have the information neccessary to do what I need.

Many thanks,
Roger
Thanks and Glad to help you.