Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Bradley Schacht

Bradley is a consultant at Pragmatic Works in Jacksonville, FL. He was an author on the book SharePoint 2010 Business Intelligence 24-Hour Trainer and tech edited the SQL 2011 Bible. His experience on the Microsoft BI platform includes DTS, SSIS, SSRS, SSAS and migrations and conversions. He has helped numerous companies in successfully developing and implementing new business intelligence solutions into their organizations. Bradley also participates as a speaker in community events like SQL Saturday, Code Camp, SQL Lunch and SQL Server User Groups. He is a contributor on sites such as BIDN.com and SQL Server Central as well as an active member of the Jacksonville SQL Server User Group (JSSUG).

Reset Identity Column in SQL

I’ll be honest, I am partially writing this because I always forget how to reset the identity column on a table and I want to be able to just pull up my blog and look it up.  Yet again today I had to do this and I couldn’t remember the exact syntax, so here it is.  The next record is going to be the seed value plus 1, or in the case of this example I will use zero so the first record is 1.  That will make my O.C.D. happy to see my table starting with a key value of 1!

Hopefully this will help some people new to T-SQL and be a simple reminder for the veterans out there.

Syntax:

1
DBCC CHECKIDENT('TableNameHere', RESEED, StartingValue - 1)

Example:

1
DBCC CHECKIDENT('DimGeography', RESEED, 0)

Comments

Posted by Anonymous on 12 August 2011

Pingback from  Dew Drop – August 12, 2011 | Alvin Ashcraft's Morning Dew

Leave a Comment

Please register or log in to leave a comment.