问题
I have a field in my SQL Server 2008 table that is auto number incremental of 1 and has over 100,000 records in it.
We are migrating servers at the moment so I'm looking at doing a little spring cleaning and will be deleting all the records from this table.
I still want the auto number incremental of 1 facility but I would like the first record to start at 102001, is this possible.
Thanks.
回答1:
Yes, simply set the start value of IDENTITY to be your chosen number. Syntax: IDENTITY (seed,increment)
CREATE TABLE Customers
(
CustomerID int IDENTITY(102001, 1),
Name nvarchar(MAX)
)
回答2:
I have used this TSQL command in the past to re-seed an auto number column in a table
DBCC CHECKIDENT ('dbo.TABLE', RESEED, 102001)
来源:https://stackoverflow.com/questions/4670020/auto-number-fields