Is it possible to set the next value of an autoincrement field in SQL Server like you can do in Postgres?
For the curious, here’s the whole backstory. My company used to use Postgres, which allows you to easily set the next value of an autoincrement field to an arbitrary value.
New company bought old company, and now we’re importing Postgres data to SQL Server. Somehow the autoincremented AcctID field on Accounts got set to a 9-digit number even though there are thousands of 8 digit numbers to be had. Apparently someone did this a while back in Postgres for some now unknown reason.
So now in the new SQL Server database, new accounts are having 9-digit account ids, but the client’s accounting software can’t deal with 9-digit account numbers, so any new accounts they add can’t be processed by their accounting department until this gets resolved.
Of course, there are up to 72 different tables which can have dependencies on the AcctID field of Accounts, and the client created about 360 new accounts before they realized the problems involved, so saving that data, truncating the table, and reinserting the data would be an onerous task.
Much better would be to set the autoincrement value of AcctID to the last 8-digit value + 1. Then at least they’d be able to add new accounts while a solution to the 9-digit accounts was being worked on. In fact they claim they only need 3 of the 360 accounts they’ve added.
So is it possible to reset the autoincrement value of a field in SQL Server like you can do in Postgres?
In SQL Server you can reset an autoincrement column like this:
You can check MSDN’s documentation about it here.