MSSQL - Reset Identity Column Value in SQL Server

Command to reset identity column:

DBCC CHECKIDENT(table_name,RESEED,0) 1 is the next value of your identity column.

Example.
Column "id" in table "customer" is an identity column.

DBCC CHECKIDENT("customer",RESEED,0) -> next id is 1.

or

DBCC CHECKIDENT("customer",RESEED,10) -> next id is 11.

If you need to check next ID you can use

DBCC CHECKIDENT("customer",NORESEED) -> you'll get these result.

"Checking identity information: current identity value '0', current column value '0'.
DBCC execution completed. If DBCC printed error messages, contact your system administrator."

Or you can use this SQL statement to get the current identity:

Example.
SELECT IDENT_CURRENT ('customer') AS Current_Identity

Popular posts from this blog

SAP CPI - Loop Process Call with SuccessFactor (oData V2)

Setting IntelliJ IDEA to run Groovy Script

C# - BASE64 to Image