During development its very common that developers create enormous amount of test record into a table and once you delete all those test records or even clean the whole table. The next record you are going to enter into this table after deleting all the test record, it won't start from zero or the next sequence number from the last record in table. Rather it will start after the last record you ever entered, even if it is not existing into the table anymore.
To over-come this problem you can simply issue the following command to reseed your table to start at 0 or whatever number you wish:
Just be careful while setting the seed value and make sure that you don't have any record with the ID higher than the seed value, which is 0 in our case here.
To over-come this problem you can simply issue the following command to reseed your table to start at 0 or whatever number you wish:
DBCC CHECKIDENT (TestTable, RESEED, 0)
Just be careful while setting the seed value and make sure that you don't have any record with the ID higher than the seed value, which is 0 in our case here.
No comments:
Post a Comment
Your comments are highly appreciated!