DEV4 Blog

  • Home
  • /
  • Blog
  • /
  • Reseeding a SQL Server Table

If you are using Identity Specification to auto increment the primary key on your table, you may want
to reset the starting increment number because you have emptied the table. This is called reseeding and can be done with the following code.

Open the SQL query pane and type:

Using YourDatabaseName
Go
DBCC CHECKIDENT ('[YourTable]', RESEED, 0)
GO

The SQL query pane will attempt to reseed the number to the last argument in CHECKIDENT so be wary if you have rows in your table when you run this. 

You can set the number to a higher value so the next row entered will be assigned a greater number.

Using YourDatabaseName
Go
DBCC CHECKIDENT ('[YourTable]', RESEED, 250)
GO

The next row inserted into YourTable will be assigned 250 as the primary key.


Published on 03 Oct 2018

Add new comment...