Thanks. This gives me a bit of extra information on top of the
research I've done on the topic. Now comes a few extended questions.
:)

1. When a cfquery has a result attribute defined, it will return data
about the query and in the case of an insert, the id of the inserted
item. The assumption is that under the hood CF is using
scope_identity() (for MSSQL). Do you have any idea if this is the
case? Just trivia and something I should test anyway.
2. From what you say of NoCount, I assume that there would be a minor
performance benefit for sql insert, update, and delete operations to
use it, correct?

Thanks

--
Michael Dinowitz




On Fri, Jan 29, 2010 at 9:24 AM, DURETTE, STEVEN J (ATTASIAIT)
<sd1...@att.com> wrote:
>
> Use SCOPE_IDENTITY().  @@Identity returns the id for the last record
> inserted. If an another insert into that table occurs between your
> insert and the select @@identity (2 different people making inserts into
> the db for example) you will get the id for the other record that was
> inserted.
>
> Scope identity only pulls the last record for the current scope. Sort of
> like putting something in a transaction. It all sticks together.
> (however putting a query in a transaction with @@identity will not solve
> the problem above).
>
> As for the SET NOCOUNT ON and SET NOCOUNT OFF, they have no effect on
> these.  The only thing that does is prevent extra network traffic by
> stopping the extra reporting of how many rows were affected for each
> piece of the query.
>
> Of course I'm assuming that this is MSSQL.
>
> Ste

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:330255
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to