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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 @@ROWCOUNT

Author  Topic 

yakoo
Constraint Violating Yak Guru

312 Posts

Posted - 2002-02-07 : 16:30:53
Does anybody know how efficient @@ROWCOUNT is.

I have a stored procedure that could be run concurrently and I want to make sure that @@ROWCOUNT will return the correct value for the appropriate stored procedure.

example
----------
[1] UPDATE Employees SET PhoneNumber = @PhoneNumber where EmployeeID = @ID
[2] if @@ROWCOUNT > 0
[3] RETURN 1
[4] else
[5] RETURN 0

sp process 1 executes line [1] (rows affected = 1)
sp process 2 executes line [1] (rows affected = 0)
sp process 2 executes line [2]
sp process 1 executes line [2]

will @@ROWCOUNT for sp process 1 be 1 or 0?


Kind of like the @@IDENTITY issue where it is better to use SCOPE_IDENTITY



Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2002-02-07 : 17:50:14
Hi

AFAIK @@Rowcount will return the correct values to each call in your example as it is applies to the current connection.

Damian
Go to Top of Page

yakoo
Constraint Violating Yak Guru

312 Posts

Posted - 2002-02-07 : 18:19:10
Thanks alot.

I wanted to be sure that the scope would be to the immediate stored procedure and not global before I actually implemented it.





Go to Top of Page
   

- Advertisement -