Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Azure Reset autoincrement

I found a lot of topics telling to use :

DBCC CHECKIDENT ('table', RESEED, 0)

But this is not supported by Azure SQL. Does somebody have any idea on how to do it easily ?
Thanks a lot !

like image 621
MaT Avatar asked Jul 25 '12 07:07

MaT


People also ask

How do I reset identity column in SQL Server?

Here, to reset the Identity column in SQL Server you can use DBCC CHECKIDENT method. Syntax : DBCC CHECKIDENT ('table_name', RESEED, new_value); Note : If we reset the existing records in the table and insert new records, then it will show an error.

How do I reset my Autoincrement ID?

Reset the auto increment fieldALTER TABLE `table` AUTO_INCREMENT = number; Replacing 'number' with the result of the previous command plus one and replacing table with the table name. If you deleted all the rows in the table, then you could run the alter table command and reset it to 0.

Can you set auto increment?

Auto-increment allows a unique number to be generated automatically when a new record is inserted into a table. Often this is the primary key field that we would like to be created automatically every time a new record is inserted.


1 Answers

DBCC CHECKIDENT is not supported for now in SQL Azure as you commented.

Check this MSDN forum post, there are some solutions proposals, maybe one of them can help you out.

like image 91
Yaroslav Avatar answered Sep 18 '22 06:09

Yaroslav