Reseeding SQL Server-s identity column

No votes yet

This post is for my personal reference since I need this once in a while and I always forget how it's done. This is usually needed when you want to "reset" some table and you can't truncate it because of foreign key constraints.

  1. DBCC CHECKIDENT (myTable, reseed, 0)
  2.  
  3. /* instead of 0, you can put other number */

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
Mollom CAPTCHA (play audio CAPTCHA)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated.
Powered by Drupal, an open source content management system