Set @@rowcount to a local var in one SP from another SP 
Author Message
 Set @@rowcount to a local var in one SP from another SP

I am using sql 2k and have a stored procedure that needs to check a
rowcount before performing a task.

I need to somehow get the rowcount of a query and set that to a local
var within my sp.  When I try to do this locally, it won't set the var
and only returns a record set.

Is there a way to call an SP from within another SP and have a return
value set to a local var?

I've tried many things and nothing works.

E.G.


Thanks

*** Sent via Developersdex http://www.***.com/ ***
Don't just participate in USENET...get rewarded for it!



Mon, 21 Jun 2004 13:05:40 GMT
 Set @@rowcount to a local var in one SP from another SP

You can return the rowcount as the return value or as an output parameter.
Examples below.

--as return value
CREATE PROC spGetRowCount
AS
SET NOCOUNT ON



GO




GO

--as output parameter
CREATE PROC spGetRowCount

AS
SET NOCOUNT ON

GO




GO

--
Hope this helps.

Dan Guzman
SQL Server MVP

-----------------------
SQL FAQ links (courtesy  Neil Pike):

http://www.ntfaq.com/Articles/Index.cfm?DepartmentID=800
http://www.sqlserverfaq.com
http://www.mssqlserver.com/faq
-----------------------


Quote:
> I am using sql 2k and have a stored procedure that needs to check a
> rowcount before performing a task.

> I need to somehow get the rowcount of a query and set that to a local
> var within my sp.  When I try to do this locally, it won't set the var
> and only returns a record set.

> Is there a way to call an SP from within another SP and have a return
> value set to a local var?

> I've tried many things and nothing works.

> E.G.


> Thanks

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Mon, 21 Jun 2004 13:57:31 GMT
 
 [ 2 post ] 

 Relevant Pages 

1. How to use a result set from one SP in another SP

2. Change system var in a SP affect other SP or not

3. How to pass Table var as param from SP to SP

4. set rowcount inside SP

5. How To set var = sp return value???

6. Error 18481 when calling remote SP from local SP

7. Can one SP call another SP in another DB on a different System

8. Passing temp table from one SP to another SP

9. using result of one SP in another SP

10. Can One SP Call Another SP

11. Process sp Result Set Within an sp?

12. Using result set of sp in sp


 
Powered by phpBB® Forum Software