GertDeWilde
GertDeWilde

Reputation: 351

Reset IDENTITY columns Manually

I see multiple topics on this issue, where you have tested with a database, and now want to reset the ids.
There are a lot of ways to do this with codes, but isn't there a way to do this manually in sql server 2008? So to just go to your table(/content) and reset the id's + clear the values. Atm, I can only go into my contents and delete these, but my id's still remain.

Similar Topic

Upvotes: 1

Views: 454

Answers (4)

GertDeWilde
GertDeWilde

Reputation: 351

So it seems that there is no manual way to reseed your table. The only way is to go to: New Query, and type like Allan S. Hansen is saying: DBCC CHECKIDENT ('', RESEED, );

where if my tabel is tblSporen from my database: BRADY, my query would be: DBCC CHECKIDENT ('BRADY.dbo.tblSporen', RESEED, 0);

Upvotes: 0

Malachi
Malachi

Reputation: 3221

Just an Idea, I don't know how this would really work in the real, but you could create a Create Table Script if you are going to clear the Table anyway, just Drop and Re-Create the table. if you are only going to do it once it shouldn't hurt anything.

Upvotes: 0

Allan S. Hansen
Allan S. Hansen

Reputation: 4081

Basically - you need to run the DBCC checkident to get the database engine to reseed.

DBCC CHECKIDENT ('<your table>', RESEED, <new seed>);

Upvotes: 5

Hedinn
Hedinn

Reputation: 864

On SQL server, if you are deleting all data and resetting an identity column, I would use Truncate http://technet.microsoft.com/en-us/library/ms177570.aspx

Upvotes: 0

Related Questions