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
 SQL Server Development (2000)
 store result of stored procedure into a cursor variable

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-06-09 : 08:21:05
Nelson P. Varghese writes "How can I store result of stored procedure into a cursor variable

Declare @cur cursor
exec @cur = sp_columns '<table_name>'

won't work

Nelson P. Varghese"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-06-09 : 08:21:16
Why would you want to?

Go to Top of Page

ajthepoolman
Constraint Violating Yak Guru

384 Posts

Posted - 2003-06-09 : 12:22:00
In your cursor, you will declare a variable to hold the return value from your stored procedure.

DECLARE @Score varchar(500)

Then somewhere in your cursor you will execute your stored procedure, passing in the necessary variables and then setting @Score equal to the Output variable in your stored procedure.

EXEC qryStoredProcedureName @intPassedInID, @txtResult = @Score OUTPUT



You stored procedure should have something like this:
CREATE PROCEDURE qryStoredProcedureName
@intRecID INT,
@txtResult varchar(500) output -- <----That is the output
AS


You can now use @Score to display data or whatever. Just remember that @Score is going to be overwritten each time the cursor fires. So any further manupulation of @Score must be done inside the cursor.

Aj

Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-06-09 : 12:40:16
quote:

"How can I store result of stored procedure into a cursor variable"



pronoun trouble -- B. Bunny



Brett

8-)
Go to Top of Page
   

- Advertisement -