Wednesday, February 2, 2011


Often we need to reseed, or reset the IDENTITY value for our tables.  This is a quick way to reseed your 'Customer' table, so the next record added starts at 100:
   DBCC CHECKIDENT('Customers' , RESEED, 100);

Remember, if your table has existing records, the next IDENTITY value will be 101.

Or, if you want to report the current IDENTITY, but you don't want to ALTER it, try this:

Maybe your table has been around forever, has been deleted from many times, and you just want to return the original seed value that was used with the table was created:
  SELECT IDENT_SEED('Customers') AS Identity_Seed;

Lastly, use this to return the increment value of your IDENTITY column:
  SELECT IDENT_INCR('Customers') AS Identity_Increment;

These are just a few tips I can offer on our IDENTITY values.  Definitely check BOL for a much greater explanation on all of the above, and more.

No comments:

Post a Comment