snippetsqlMinor
How to get Identity Column to jump ahead (by say 1000) on SQL Server 2012
Viewed 0 times
identityjump2012columnsqlsayget1000howserver
Problem
I am using SQL Server 2012 and I would like to keep my pre-existing data but to cause the ID (identity) column to skip by 2000 rows.
Why is this happening? I have a scenario where I may have transactions happening on a standby server which I will need to copy to current server. I want the IDs to match. Therefore I do not want any new transactions on this server that would have the same ID as my standby server.
Hopefully this makes sense!! Thank you
Why is this happening? I have a scenario where I may have transactions happening on a standby server which I will need to copy to current server. I want the IDs to match. Therefore I do not want any new transactions on this server that would have the same ID as my standby server.
Hopefully this makes sense!! Thank you
Solution
You could do this by running something like
This would reseed your table identity to be 2000 higher than it currently is and seems like it should resolve what you are looking to do.
declare @newid int;
select @newid = IDENT_CURRENT('YourTable') + 2000;
dbcc checkident('YourTable', reseed, @newid);This would reseed your table identity to be 2000 higher than it currently is and seems like it should resolve what you are looking to do.
Code Snippets
declare @newid int;
select @newid = IDENT_CURRENT('YourTable') + 2000;
dbcc checkident('YourTable', reseed, @newid);Context
StackExchange Database Administrators Q#75152, answer score: 8
Revisions (0)
No revisions yet.