Thanks Adam will give this a try
cheers

>>> [EMAIL PROTECTED] 11/26/03 10:35am >>>
Hi Brian,

> Is there a way to get the primary key (autonumber) 
that would be allocated during an insert statement in a cfquery?

Here is some code we use with great success.. Using MSSQL

<cfquery name="insertThis" datasource="#request.datasource#">
SET nocount ON
INSERT INTO     this_table
                (this_field)
VALUES  (<cfqueryparam value="1" cfsqltype="CF_SQL_NUMERIC">)
SELECT @@identity as newID
SET nocount OFF
</cfquery>
<cfset newPK = insertThis.newID>

Regards,

Adam Chapman
Virtualtours.com.au
mailto:[EMAIL PROTECTED] 

Phone: 1300 366 122
Int: +61 3 9720 5733
Fax: +61 3 9720 6377

---
You are currently subscribed to cfaussie as:
[EMAIL PROTECTED] 
To unsubscribe send a blank email to
[EMAIL PROTECTED] 

MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
http://www.mxdu.com/ + 24-25 February, 2004

---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
http://www.mxdu.com/ + 24-25 February, 2004

Reply via email to