How to reseed value of identity field in Sqlserver.

We can use “DBCC CHECKIDENT” to reset the value of Identity field.

create table tIdentity(id int identity(1,1), name nvarchar(50))

insert into tIdentity(name) values(‘sunil’),(‘Maya’)

select * from tIdentity

/* Now using DBCC CHECKIDENT we reseed the value of identity field to 1001 */
DBCC CHECKIDENT (tIdentity,’reseed’,1012)

insert into tIdentity(name) values(‘sunil’),(‘Maya’)

select * from tIdentity

drop table tIdentity

1

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s