Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I reset an increment identity's starting value in SQL Server

I would like to have a nice template for doing this in development. How do I reset an increment identity's starting value in SQL Server?

like image 471
Joel Meador Avatar asked Aug 19 '08 21:08

Joel Meador


People also ask

How do you reset the column values in a auto increment identity column?

In MySQL, the syntax to reset the AUTO_INCREMENT column using the ALTER TABLE statement is: ALTER TABLE table_name AUTO_INCREMENT = value; table_name. The name of the table whose AUTO_INCREMENT column you wish to reset.

How do you restart a sequence in SQL Server?

In the SSMS GUI, navigate to Database Folder – [Database Name] – Programmability Folder – Sequences Folder. 4. Select the “Restart sequence” checkbox. You can enter the value you want to reset the sequence to, or keep the default value.

How can change auto increment column in SQL Server?

ALTER TABLE Inventory MODIFY COLUMN item_number INT AUTO_INCREMENT=50; After running this code, future item IDs will start at an item_number of 50 and increment by 1. To change the starting increment value and increment in SQL Server, set your non-default values during table creation.


1 Answers

DBCC CHECKIDENT('TableName', RESEED, 0) 
like image 88
Ryan Sampson Avatar answered Sep 29 '22 14:09

Ryan Sampson