[thelist] @@IDENTITY w/SQL 7 - ColdFusion query

databarn databarn at airmail.net
Sat Aug 11 03:32:08 CDT 2001


If that is CF specific, great.  But that SQL structure, as such, is dangerous to your intent in a multiuser environment unless CF handles the multiple queries internally as a single query and presents it to SQL Server as such  I'd be a bit dubious about it for a while, until such time as you can reliabley ascertain that it really does what you want.

Make a good day . . .
			 . . . barn
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you don't know where you're going, any road will take you there.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 	
_______________________________________
From:	Erik Mattheis [gozz at gozz.com]
To:	evolt [thelist at lists.evolt.org]
Subject:	Re: [thelist] @@IDENTITY w/SQL 7 - ColdFusion query
Time:	8/11/2001 at 1:48AM

Thanks people ... I googled the Internet again and came up with a
solution different that what has been suggested or I'd seen before:

<cfquery datasource="dsn" name="the_query">
   SET NOCOUNT ON
   INSERT INTO table_name([columns])
   VALUES([values])
   SELECT whatever_id = @@IDENTITY
   SET NOCOUNT OFF
</cfquery>

This results in #the_query.whatever_id# being the ID of the row that
was just created. I've no idea what those no count things are doing
and I don't see the syntax of SELECT [variable] = @@IDENTITY anywhere
in the SQL 7 books online; but I don't have to understand it, just so
my magic electric box does!
--

- Erik Mattheis








More information about the thelist mailing list