I've got a strange situation with some tables in my database starting its IDs from 0, even though TABLE CREATE has IDENTITY(1,1). This is so for some tables, but not for others. It has worked until today.
I've tried resetting identity column:
DBCC CHECKIDENT (SyncSession, reseed, 0);
But new records start with 0. I have tried doing this for all tables, but some still start from 0 and some from 1.
Any pointers?
(i'm using SQL Server Express 2005 with Advanced Services)
From DBCC CHECKIDENT
So, this is expected for an empty or truncated table.
Try this
If you pass a reseed value the DB will start the identity from that new value:
You don't have to pass the a value though, if you don't
IDENTITY(a,b)
will be used instead:This is usually better practice, as it leaves the table closer to its initial created state.
This is a way to start an
id
withZero(0)
, then delete all the rows from table and again put the data back into the table.I have the same problem, restoring from a backup after modifying the DB. I just add a dummy record and then delete it... then set RESEED to 0. Seems to work.
This is logical, since you've changed (reseeded) the identity value to zero ?
will reseed your identity column, and make sure that the first new record will start with 1.