Ehsan
Ehsan

Reputation: 3491

Reset identity field in sql by one error

How can I reset identity field in a table in database by '0' value?

I used of this script:

DBCC CHECKIDENT({table name}, reseed, 0)

But this has a error by this message :

Incorrect syntax near CHECKIDENT

What is CHECKIDENT?

Upvotes: 0

Views: 500

Answers (2)

Anusha Subashini
Anusha Subashini

Reputation: 397

Try this:

DBCC CHECKIDENT ("DBO.TABLENAME",RESEED)

Upvotes: 0

marc_s
marc_s

Reputation: 755421

I don't know what you're doing - but this works perfectly well for me:

DBCC CHECKIDENT('EMP', reseed, 0)

Results in:

Checking identity information: current identity value '12', current column value '0'.
DBCC execution completed. If DBCC printed error messages, contact your system administrator.

You need to make sure to put your table name into single quotes: use 'EMP' - not EMP

CHECKIDENT (from: check identity) is just the name of the command for the DBCC function in SQL Server (there are a lot more DBCC....... commands available)

Upvotes: 2

Related Questions