Jeff,
I think this is what you're after:
<cfquery name="enterRecord" datasource="#attributes.DSN#" dbtype="ODBC">
SET NOCOUNT ON
INSERT INTO myTable (name, ID)
VALUES ('#attributes.name#', #attributes.ID#)
SELECT newID = @@IDENTITY
SET NOCOUNT OFF
</cfquery>
<cfset newID = enterRecord.newID>
Cheers,
-Max
At 12/30/2000 08:26 PM -0800, you wrote:
>I know it is a taboo to use Identity fields in SQL Server with Fusebox, but
>if I were using Identity fields, how could I return the last inserted ID
>without having to run another query? In a stored procedure in SQL Server,
>you can refer to the @@Identity property to return the last ID inserted into
>the table's identity field. Is there any way to do this in ColdFusion? I
>am trying to keep from writing two queries, and also don't want to write a
>stored procedure. In the past, I thought I read that this could be done.
>
>Anyone done this before?
>
>
>Thanks,
>
>Jeff Stone
>[EMAIL PROTECTED]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists