Sql-server – What Happens When Identity Range IsExceeded

replicationsql server

I am using identity columns in my merge replication solution to give people an id they can tell us over the phone (i.e. to support staff). A rowguid column would be too hard for this.

I have noticed that int identity columns are replicated no trouble, and each client subscription has a range of identity values it can use.

i.e. select * from MSmerge_identity_range

range_begin    range_end    next_range_begin    next_range_end
6003           7003         7003                8003

I'm just wondering what happens if you do some kind of bulk insert for instance which inserted 5000 new records into this table. What would happen to the identity column then?

Best Answer

If you attempt to bulk insert more rows then available identity values between syncs you will get an error:

The identity range managed by replication is full and must be updated by a replication agent.

The key here is to allocate range sizes large enough to accommodate for the amount of inserts that may occur between syncs. You can specify the range sizes in article properties when adding articles to the publication.