How would the NOCOUNT setting affect the @@IDENTITY being returned?  Doesn't
seem like it from the sql docs:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_
set-set_3ed0.asp

SET NOCOUNT
Stops the message indicating the number of rows affected by a Transact-SQL
statement from being returned as part of the results.

Syntax
SET NOCOUNT { ON | OFF } 

Remarks
When SET NOCOUNT is ON, the count (indicating the number of rows affected by
a Transact-SQL statement) is not returned. When SET NOCOUNT is OFF, the
count is returned.

The @@ROWCOUNT function is updated even when SET NOCOUNT is ON.

SET NOCOUNT ON eliminates the sending of DONE_IN_PROC messages to the client
for each statement in a stored procedure. When using the utilities provided
with MicrosoftR SQL ServerT to execute queries, the results prevent "nn rows
affected" from being displayed at the end Transact-SQL statements such as
SELECT, INSERT, UPDATE, and DELETE.

For stored procedures that contain several statements that do not return
much actual data, this can provide a significant performance boost because
network traffic is greatly reduced.

The setting of SET NOCOUNT is set at execute or run time and not at parse
time.


-----Original Message-----
From: Mark A Kruger [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 11, 2005 1:22 PM
To: CF-Talk
Subject: RE: retrieve ID from db insert

Sometimes you need to fiddle with the "NOCOUNT" setting to make it work
reliably.  It depends on how the SQL server is configured.

SET NOCOUNT ON

   Insert into table (cols) values (values)
   select @@IDENTITY as maxid

SET NOCOUNT OFF

This is especially true if you are updating more than 1 statement inside the
SQL block.

-mk

-----Original Message-----
From: Aaron Rouse [mailto:[EMAIL PROTECTED]
Sent: Monday, July 11, 2005 12:07 PM
To: CF-Talk
Subject: Re: retrieve ID from db insert


I always just use triggers for when inserting, but it seemed like the worry
here was to know the ID after the insert to I'd guess display to the user.
How would a trigger help for that need?

On 7/11/05, Eddie Awad <[EMAIL PROTECTED]> wrote:
>
>
> Of course, you could also just create a "when-insert" trigger on the
> table to automatically populate the id column so you do not have to
> worry about it in your "insert" statements.
> --
> Eddie Awad.
> http://awads.net/
>
>






~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:211560
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to