I saw a demonstration where the code below returned the wrong max(id).  My
understanding is that
"SELECT @@IDENTITY AS NewID" is really the only way to insure you get the
correct ID

-----Original Message-----
From: nagraj [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 15, 2002 1:06 AM
To: CF-Talk
Subject: Re: How do you get the ID number of newest record added to a
table?


Hi,

Put this code under transaction to get the row inserted and get just
inserted rowID


<cftransaction>
    <cfquery datasource="dsn" name="insdata">
        insert into table1(col1,col2) values(#val1#,#val2#)
    </cfquery>
    <cfquery datasource="dsn" name="getmaxid">
        select max(id) from table1
    </cfquery>
</cftransaction>

Cheers.

Nagaraj

----- Original Message -----
From: <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Friday, February 15, 2002 2:17 PM
Subject: Re: How do you get the ID number of newest record added to a tab
le?


> How do you get the row ID number of the newest record added to a table?
>
> I want to insert a record and then outout the info from that record by
the
> autocreated row ID number, because there's no other unique identifier f
or
> the info in each record.
>
> Is there a function that tells you the highest row ID number, which
> consequently would be the newest and latest addition to that table?
>
>
>
>
>

______________________________________________________________________
Dedicated Windows 2000 Server
  PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation � $99/Month � Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusiona
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to