0

How to reset the value after deleting particular record in sql using mvc2

ex records are: 1,2,3 deleted record:3

now i am adding new record .it should have the id 3 not 4. what can i do for that??

user7415073
  • 290
  • 4
  • 22

2 Answers2

1

You can Reseed your table like this :

DBCC CHECKIDENT ('[YourTableName]', RESEED, 0);
GO
Suman Pathak
  • 300
  • 1
  • 8
0

Well this is not a good idea if the id is associated with other tables it will make a big mess in your database, however I do not know in which context you want to use this so I leave it to your discretion. But instead of deleting you can disable the auto incrementer of the table in question, and write a bit to add the free ids. Obs; Continues to be a bad idea!

demopix
  • 159
  • 6