tags:

views:

29

answers:

1

My scenario is... I create Table as(id identity(1,1) not null,name varchar(500),category varchar(50))... i try to insert values.. displays has (1,'sede','diabetes') and it goes has 1,2,3. But when i delete the total content.. once again insert it starts with 4,5,6...

I don want this type of inserting...When content i deleted it should start from 1,2,3..

How can i achieve this.. i need it in stored procedure.. Any idea..

+2  A: 

You can reset the Identity seed by executing dbcc checkident

DBCC CHECKIDENT ("TableName", RESEED, 0)
Barry
@Barry - on a regular basis? Resetting all IDs when one is deleted?
Oded
@Oded - No, I wouldn't recommend doing this after every delete. I was under the impression that the delete was a one off or infrequent. Maybe @Shiny could clarify.
Barry