For SQL server
<CFQUERY name="Whatever" datasource="#Application.DSN#">
SET NOCOUNT ON
INSERT INTO YourTable
(Field1, Field2)
VALUES ('a','b')
SELECT TheID = @@IDENTITY
SET NOCOUNT OFF
</CFQUERY>
In Access you will have to query for the latest record:
<cftransaction>
<cfquery ...>
INSERT ...
</cfquery>
<cfquery name="bob" ...>
SELECT max(ID) as MaxID
FROM TheTable
</cfquery>
</cftransaction>
You can then refer to the latest record's ID as bob.maxid
Steve
> -----Original Message-----
> From: Daniel Kemp [mailto:[EMAIL PROTECTED]]
> Sent: Monday, October 23, 2000 11:30
> To: CF-Talk
> Subject: SQL: Getting values from a just inserted record.
>
>
> I know this has been asked before a while back, but I can find the
> mail which covered it, so here's the question.
>
> I add a record which is using a "uniqueidentifier" as the key, how can
> I then get the value of that field, without having to do a search on
> the rest of the data I've just added (which ain't unique enough)?
>
> I seem to remember that you used some SQL @somethingOrOther to
> reference it, but can pin down a solution.
>
> Cheers,
>
> Dan.
>
>
>
>
> This message is intended only for the use of the person(s) ("the
> intended recipient(s)") to whom it is addressed.
>
> It may contain information which is privileged and confidential
> within the meaning of the applicable law. If you are not the
> intended recipient, please contact the sender as soon as
> possible.The views expressed in this communication may not
> necessarily be the views held by Live Information Systems Limited.
>
>
> ------------------------------------------------------------------
> ------------------------------
> Archives: http://www.mail-archive.com/[email protected]/
> Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
> or send a message with 'unsubscribe' in the body to
> [EMAIL PROTECTED]
>
------------------------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message
with 'unsubscribe' in the body to [EMAIL PROTECTED]