Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 5123

How to reset an Identity column using SQL server Management Studio

$
0
0

 

I found this neat trick that means I don't have to write a whole bunch of SQL.

 

If you want to reset the identity values for a table, because you have deleted and added rows, and now want to re-number them from a given value, do the following:

Go to the design view for the table, and delete the Identity column.

Re-add it as you would normally.  Set it to be an identity, and set your starting seed value, as well as your increment. 

Click Execute.  Voila.  All values are reset to begin at your seed value, and increment by the increment value.

No need to create temporary tables or drop any rows.

 

If you think this is a "Bad Idea", please tell me, as this is a n00b's way around coding SQL.


Viewing all articles
Browse latest Browse all 5123

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>