I have seen similar behaviour, I think it was with CF 8.
Using the Set nocount on option seemed to help.
<cfquery datasource="ds" name="qInsert">
set nocount on
INSERT
INTO TableName (Col1)
VALUES ('foobar')
SELECT @@IDENTITY AS 'NewID'
Set nocount off
</cfquery>
PS: SCOPE_IDENTITY() is a better choice. You never know when your table may
have an underlying insert trigger….
From: [email protected] [mailto:[email protected]] On Behalf Of
Paul Kukiel
Sent: Friday, 13 August 2010 5:27 PM
To: [email protected]
Subject: Re: [cfaussie] CF8 and MSSQL 2005/2008
Steve don't use @@identity you can achieve this result with CF alone:
http://cookbooks.adobe.com/post_Getting_the_ID_of_the_Last_Record_Inserted_Into_a-16522.html
and with CF9 its more generic:
http://cookbooks.adobe.com/post_Generated_key___Get_the_ID_of_the_inserted_record-16593.html
Paul.
On Fri, Aug 13, 2010 at 5:19 PM, Steve Onnis
<[email protected]<mailto:[email protected]>> wrote:
Is there an updated driver for SQL Server? I have come across this issue where
if i run this query:-
<cfquery datasource="ds" name="qInsert">
INSERT
INTO TableName (Col1)
VALUES ('foobar')
SELECT @@IDENTITY AS 'NewID'
</cfquery>
Under CF8 it errors saying qInsert is undefined but under CF9 it runs fine.
Steve
--
You received this message because you are subscribed to the Google Groups
"cfaussie" group.
To post to this group, send email to
[email protected]<mailto:[email protected]>.
To unsubscribe from this group, send email to
[email protected]<mailto:cfaussie%[email protected]>.
For more options, visit this group at
http://groups.google.com/group/cfaussie?hl=en.
--
Paul Kukiel
--
You received this message because you are subscribed to the Google Groups
"cfaussie" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cfaussie?hl=en.
--
You received this message because you are subscribed to the Google Groups
"cfaussie" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cfaussie?hl=en.