Monday, February 13, 2012

[*-)] About Auto Increment Field

Hi,

I have one Auto increment field in the table.

I have a problem that suppose I have 10 Records in the table, Now If someone delete record no 3 and 5 then it has 8 records.

But The field will give 11 no to new record I want it first fill 3 and 5 then give 11 to the new record.

Is it possible with the auto increment field in sql server 2005.

No it's not possible with autoincrement fields. You would have to create your own primary key field, and query the table to get the lowest available number everytime you performed an insert. I would never recommend doing this. It's a potential nightmare, and I can't think of one single good reason for doing it. All you need is a unique identifier for each row. It doesn't matter if it's not nice and pretty (in terms of a sequential series), so long as it works.

No comments:

Post a Comment