Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to reset count for identity field?
Message
General information
Forum:
ASP.NET
Category:
Databases
Miscellaneous
Thread ID:
00819923
Message ID:
00820628
Views:
18
Thanks for the tip—I'll keep that close at hand.

This is during development only, and I've got a copy of some production data in my development tables. When I delete the records created by my testing, I like to have the counter reset.

Now that I think about it, though, it's probably not all that important, since when I move the tables back into production (I've modified the structures) the identity fields probably aren't copied over with it. They should correct themselves according to the table they're in, yes?

IOW, like so:
   Test     Prod
  ------   ------
    1        1
    2        2
    3        3
    7        4
    8        5
    9        6
Correct?





>You can use DBCC CHECKIDENT() to reset the next identity to a new value. Why do you want to do this after deleting a row?
>
>-Mike
>
>>I'm having trouble figuring out how to reset an identity field's sequential count in a table, after I manually delete one or more records.
>>
>>As it is, when I delete the last record in a table, the next record I add adopts the next higher number, as though I hadn't deleted it at all.
>>
>>I tried changing the seed, but that didn't help, so I set it back to 1.
>>
>>TIA,
>>Jeff

Read about the greatest fraud in the history of mankind.
See TaxableIncome.net.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform