Reset Identity Column Value

Posted by Rahul on July 11, 2010
  0 comments

Easiest way to reset the identity column value in MSSQL is to use 'TRUNCATE TABLE' on the table.
This will reset the identity column value.This will work only if the table has no references made by any child.
Syntax:

    truncate table TABLENAME;

For tables that are referenced by other tables we can use 'DBCC CHECKINDENT' Syntax;
use databaseName;
go 
DBCC CHECKIDENT ('tableName','reseed',reseedvalue)
go

Comments


Leave a comment

Tell us about yourself
Your Name     (required field)
Your Email Address     (required field)
Website URL      
Comment and preferences
Your Comment  
   
  Subscribe to this comment thread