this blog contains information for .net and sql stuffs. You can find various tips and tricks to overcome problem you may be facing in ...

Thursday, December 4, 2008

Reassing AutoIncrement Field Value

If we have deleted all values in a table that contains auto-increment field. Now if we add any values to table then autoincrement field value would be start from last deleted value + step of increment

Say an example 
you have last value of auto increment field is  10 in deleted records and now want to add new record then increment value would be 11 if step is 1.

So what to do if we want to reevalutate value of autoincrement to 1.

Just fire below syntax 
DBCC CHECKIDENT(table Name,RESEED,0)
This will reevalute value of autoincrement field to 0.

Hope this will be useful ....

No comments: