Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to find next available ID Slot using SQL?

4 views
Skip to first unread message

Jack

unread,
Mar 2, 2008, 3:20:21 AM3/2/08
to
I am not familiar with databases, so I am hoping someone could help.
If some records in a table sometimes get deleted, their IDs become
available.
How do I reuse these IDs so that next time a record is added, the SQL
statement automatically would help me find this empty slot?
Thanks
Jack


Ed Murphy

unread,
Mar 2, 2008, 4:38:13 PM3/2/08
to
Jack wrote:

You shouldn't try to do this at all.

Aidy

unread,
Mar 3, 2008, 10:09:03 AM3/3/08
to
As advised, just don't do this...use an IDENTITY and keep incrementing the
IDs. At a push you could use a DELETE TRIGGER to track when IDs have been
deleted and insert those "available" IDs into another table. This procedure
will just give you a concurrency nightmare though.

"Jack" <j...@knight.com> wrote in message news:47ca6346$1...@127.0.0.1...

0 new messages