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
LVL 2
Roger AlcindorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Raja Jegan RSQL Server DBA & Architect, EE Solution GuideCommented:
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.
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
when in replication, the only "secure" primary key method is the use of uniqueidentifiers. they are globally unique
will require some application changes, though :/(
0
Raja Jegan RSQL Server DBA & Architect, EE Solution GuideCommented:
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.
0
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

Roger AlcindorAuthor Commented:
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

 
0
Raja Jegan RSQL Server DBA & Architect, EE Solution GuideCommented:
>> where is the information kept that determines the next value of the Identity for any particular table such that I can change it?

Then IDENT_CURRENT( 'table_name' ) should help you out.

IDENT_CURRENT( 'table_name' ) Returns the last identity value generated for a specified table or view in any session and any scope.

Hence the next value would be IDENT_CURRENT( 'table_name' ) + 1 / x where x represents the increment value for each and every identity column.

Once you identify the next value, then you have to apply DBCC CHECKIDENT to reseed the values like

DBCC CHECKIDENT ('table_name', RESEED, y)
where y = IDENT_CURRENT( 'table_name' ) + 1 / x

Hope this helps
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Roger AlcindorAuthor Commented:
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
0
Raja Jegan RSQL Server DBA & Architect, EE Solution GuideCommented:
Thanks and Glad to help you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.