PC Review


Reply
Thread Tools Rate Thread

concurrency - Rows affected (getting the right one from a stored procedure)

 
 
Jeff Jarrell
Guest
Posts: n/a
 
      19th Jul 2005
I know this may be a sql thing but I would expect someone to have dealt with
this.

I have some update stored procedures with many steps. normally, my stored
procedures "set nocount off".

so the rowsAffected = ExecuteNonQuery doesn't return anything but 0. So I
turn it on (nocount off), but it is very easy to mess up what step has the
nocount on\off (as time goes on, changes, etc) . The proper "Rows Affected"
might be the first step, might be the last step, might be somewhere in
between.

In my stored procedure I'd like to capture the row's affected in the right
step, and then force the proper return at the end of the stored procedure.

Any ideas on this?

thanks,
jeff






 
Reply With Quote
 
 
 
 
Val Mazur \(MVP\)
Guest
Posts: n/a
 
      19th Jul 2005
Hi Jeff,

You could query @@ROWCOUNT variable using SELECT @@ROCOUNT. It will return
you number of the affected records, but it return value just for the last
statement. If you need to get accumulated value, then you would need to
query it after each statement and sum it up
--
Val Mazur
Microsoft MVP

http://xport.mvps.org



"Jeff Jarrell" <(E-Mail Removed)> wrote in message
news:uFZLVs$(E-Mail Removed)...
>I know this may be a sql thing but I would expect someone to have dealt
>with this.
>
> I have some update stored procedures with many steps. normally, my stored
> procedures "set nocount off".
>
> so the rowsAffected = ExecuteNonQuery doesn't return anything but 0. So I
> turn it on (nocount off), but it is very easy to mess up what step has the
> nocount on\off (as time goes on, changes, etc) . The proper "Rows
> Affected" might be the first step, might be the last step, might be
> somewhere in between.
>
> In my stored procedure I'd like to capture the row's affected in the right
> step, and then force the proper return at the end of the stored procedure.
>
> Any ideas on this?
>
> thanks,
> jeff
>
>
>
>
>
>



 
Reply With Quote
 
Jeff Jarrell
Guest
Posts: n/a
 
      19th Jul 2005
It's great your online to help my poor tired eyes.

Now with your help, I am able to simple do a
select @iRowCount = @@ROWCOUNT
after the step that I want to capture, then return that value at the end.

easy enough, thanks,
jeff

"Val Mazur (MVP)" <(E-Mail Removed)> wrote in message
news:uxC%23i2$(E-Mail Removed)...
> Hi Jeff,
>
> You could query @@ROWCOUNT variable using SELECT @@ROCOUNT. It will return
> you number of the affected records, but it return value just for the last
> statement. If you need to get accumulated value, then you would need to
> query it after each statement and sum it up
> --
> Val Mazur
> Microsoft MVP
>
> http://xport.mvps.org
>
>
>
> "Jeff Jarrell" <(E-Mail Removed)> wrote in message
> news:uFZLVs$(E-Mail Removed)...
>>I know this may be a sql thing but I would expect someone to have dealt
>>with this.
>>
>> I have some update stored procedures with many steps. normally, my
>> stored procedures "set nocount off".
>>
>> so the rowsAffected = ExecuteNonQuery doesn't return anything but 0. So
>> I turn it on (nocount off), but it is very easy to mess up what step has
>> the nocount on\off (as time goes on, changes, etc) . The proper "Rows
>> Affected" might be the first step, might be the last step, might be
>> somewhere in between.
>>
>> In my stored procedure I'd like to capture the row's affected in the
>> right step, and then force the proper return at the end of the stored
>> procedure.
>>
>> Any ideas on this?
>>
>> thanks,
>> jeff
>>
>>
>>
>>
>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
stored procedure - ref cursor - no rows =?Utf-8?B?TWlrZSBBbmRlcnNvbg==?= Microsoft Dot NET Framework 0 24th Mar 2005 04:45 PM
Concurrency violation: the UpdateCommand affected 0 records. JRH Microsoft ADO .NET 1 12th Nov 2004 10:34 PM
Concurrency violation: The update command 0 rows affected Dzemo Microsoft ADO .NET 4 10th Aug 2004 08:54 PM
Concurrency violation: The UpdateCommand affected? Dzemo Microsoft VB .NET 0 9th Aug 2004 09:50 AM
Concurrency Error:0 Records Affected Bob Morris Microsoft ADO .NET 2 7th Oct 2003 06:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:25 AM.