Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 No. of Rows effected

Author  Topic 

svallamreddy
Starting Member

4 Posts

Posted - 2007-06-12 : 05:56:15
Hi,

In a procedure I want to know the no. of rows effected.

That means. No of rows inserted, updated , and no of records retrieved by an SQl statement.

Is there any way to know.

Thanks

Sreenu

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-06-12 : 06:02:45
use select @@rowcount after your query


KH

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-06-12 : 08:42:57
quote:
Originally posted by khtan

use select @@rowcount immediately after your query


KH





Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-06-12 : 11:31:36
quote:
Originally posted by madhivanan

quote:
Originally posted by khtan

use select @@rowcount immediately after your query


KH





Madhivanan


Failing to plan is Planning to fail



Madhi

thats a bad way to increase your post count
It may be legal but its not fair..


Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-06-12 : 11:35:30
quote:
Originally posted by dinakar

quote:
Originally posted by madhivanan

quote:
Originally posted by khtan

use select @@rowcount immediately after your query


KH





Madhivanan


Failing to plan is Planning to fail



Madhi

thats a bad way to increase your post count
It may be legal but its not fair..


Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/


In fact there is difference between after and immediately after

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-06-12 : 11:41:25
yeah ...yeah....

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2007-06-12 : 11:54:20
Well the real answer is

DECALRE @rowcount int, @error int
SELECT @rowcount = 0

>> SQL Statement

SELECT @rowcount = @rowcount + @@ROWCOUNT, @error = @@ERROR



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -