Hi there
Ok here is my problem.
Lets say i have 20 rows in my table and i delete 19 and add 1.
The primary key's will be 1 and 21, my question is how do i get it to say 1 and 2 ?
looks like your table primary key is an identity column.
Why do you want to do this ? What if you delete a column and add another again ? Do you want to keep repeating this ?
DBCC
CHECKIDENT(tableName, RESEED, new_identity_value)Make sure to set the new identity value to the max of the current identity fields. i.e. run something with logic like:
var maxIdentity = SELECT MAX(ID) FROM tableName
DBCC CHECKIDENT(tableName, RESEED, maxIdentity)
If your last identity was 1 after the delete, the next row entered will be 2.
No comments:
Post a Comment