Groups | Blog | Home
all groups > sql server (alternate) > august 2003 >

sql server (alternate) : Stored Procedure into a Cursor


humberto.zamarron NO[at]SPAM tycoelectronics.com
8/13/2003 9:09:48 AM
Hi guys!!

I am trying to fill a cursor with the results of a Stored
Procedured, but SQL give me an syntax error message , does any one can
give me some help

I am using SQL Server, this is the first lines of my code

DECLARE FRates_Cursor CURSOR FOR
exec GET_FJRs_Eng 'all'
OPEN FRates_Cursor

if I run just the exec GET_FJRs_Eng 'all' line it give me the data
results I am trying to put into the cursor, what that means is the
stored is working fine


Trevor Best
8/13/2003 7:49:32 PM
On 13 Aug 2003 09:09:48 -0700 in comp.databases.ms-sqlserver,
[quoted text, click to view]

<aol>If there is a way I'd like to know too </aol>:-)

I tried with sp_who with no luck so what I did was copied the SQL out
of sp_who and used the select statement that it uses. That may get you
a workaround for now but if the original SP changes then you have to
remember to change the other one as well :-\

--
Ride Free (but you still have to pay for the petrol)

Erland Sommarskog
8/13/2003 8:30:50 PM
[posted and mailed, please reply in public]

Humberto Zamarron (humberto.zamarron@tycoelectronics.com) writes:
[quoted text, click to view]

Well, SQL Server permits you to pass a cursor variable from a stored
procedure to another. It sounds as if this is something you could have
use for here. Please, refer to Books Online for details. And don't
ask *me* about it, because I have never used the feature, and I guess
that I never will.

Another possibility is to get the data into a temp table, and work
from there. For discussion on this, see an article on my web site:
http://www.algonet.se/~sommar/share_data.html.


--
Erland Sommarskog, SQL Server MVP, sommar@algonet.se

Books Online for SQL Server SP3 at
AddThis Social Bookmark Button