Friday, June 12, 2015

Reseeding the Primary Key/ID column of a SQL Table

If you ever need to remove all the records from a SQL database table and then reseed/reset the value of the primary key/ID column, here are the Transact-SQL queries that you can use:

USE [DatabaseName]
TRUNCATE TABLE [TableName]
DBCC CHECKIDENT ("TableName", RESEED, 1);

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.