But won't it eventually come back in and fill in some of those ones that
were previously deleted?  As in your example, at some point won't
another item get assigned the value of 4?

John Burns

-----Original Message-----
From: Eric Creese [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 11, 2004 1:13 PM
To: CF-Talk
Subject: RE: Reliable way to get ID of inserted record

As far as I know, whatever the maxid is at the time you will get next
MaxID +1. However if you are deleting the last record and then adding a
new one, In SQLServer you will get the following.


ID    Value
1    a
2    b
3    c
4    d


ID    Value
1    a
2    b
3    c
4    d --Remove


  
ID    Value
1    a
2    b
3    c


add a new record
  
ID    Value
1    a
2    b
3    c
5    d

-----Original Message-----
From: Burns, John [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 11, 2004 12:03 PM
To: CF-Talk
Subject: Reliable way to get ID of inserted record

I know this came up last week or so, but I believe the answer came for a
mySQL database.  I need a way in MS SQL to get the last inserted record
via CF.  I have a query inserting a row into the table with an
auto-increment ID. I need to insert that ID into a separate table in
another query so I first need to find out what ID it got assigned.  I've
got it all wrapped in <cftransaction> but I'm not sure if max(id) is the
best way to get the ID, because if rows get deleted, won't SQL
automatically assign those values to new rows at some point, therefore
negating the max() idea?

John Burns
  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to