Is it possible to manage an identity range in SQL Server?
If I set seed in DB one on 1 and in DB two on 10000
In this scenario if I sync both DB’s, DB one just adds on 10000
Let’s say I want this:
- DB1 -> id start [0 – 9000]
- DB2 -> id start [10000 – 19000]
SOLUTION:
ALTER TABLE dbo.* WITH NOCHECK
ADD CONSTRAINT Id_Range_Constraint
CHECK(ID BETWEEN 10000 AND 19999)
You could create constraints in both databases for the ranges specified in your question. But keep in mind that
INSERTwill fail as soon as records fall outside that range.Something along these lines, for SQL Server. Other RDBMS syntax will vary slightly: