all groups > sql server programming > may 2006 >
You're in the

sql server programming

group:

Accessing stored proc multiple return values


Accessing stored proc multiple return values evs
5/30/2006 9:38:45 PM
sql server programming: Hi,

I have a problem. I have two stored procs. One I am building currently
(sp_load) and another that is already in the data warehouse and which I
have no control over (sp_log_event).

sp_log_event is for control logging. It accepts a process name
parameter. It outputs 3 return parameters by issuing the following
command:

SELECT
load_id,
last_succ_load_id,
datEventDate
FROM
ctl_event_log_header
WHERE
load_Id = @intLoadId


I am no expert on this but as I understand it these are technically not
output parameters. If I create an Execute SQL Task in DTS I have the
option of setting these 3 return values to my global variables in my
package - which is easy enough and I am already doing this.

However my problem is that I now need to call this (sp_log_event) from
within the stored proc I am creating (sp_load). Something like EXEC
MY_SP @processname

If the return was an output parameter i could simply do EXEC MY_SP
@processname, @loadid output

Also if it was just one return value I could do
EXEC @loadid = (MY_SP @processname)

But it is neither of these scenarios and I can't work out how I can get
access to these 3 returned values from the confines of my procedure.
load id is a primary key so the select will definitely only return one
record. how do i get access to the 3 return variables and assign them
to variables within my stored proc (sp_load)
Re: Accessing stored proc multiple return values evs
5/30/2006 10:09:45 PM
Hi Uri,

Thanks for the reply. First of all, what is BOL? :)

Second of all - I am not actually naming my stored procs like that. I
just used that for simplicity. They are actually USP_CTL_xxx and
USP_ETL_xxx

Cheers though.


[quoted text, click to view]
Re: Accessing stored proc multiple return values Uri Dimant
5/31/2006 12:00:00 AM
evs
BOL -Books On Line (tool suppliedb by MS with SQL Server)

[quoted text, click to view]
I was referencing to <(sp_log_event). from your previous post






[quoted text, click to view]

Re: Accessing stored proc multiple return values Uri Dimant
5/31/2006 12:00:00 AM
evs
BOL has very good examples how to use storerd procedure that has a few
OUTPUT parameters

BTW , it is really bad practice to use sp_ prefix to name stored
procedures, because in that way SQL Server is going to check for system
stored procedures first




[quoted text, click to view]

Re: Accessing stored proc multiple return values evs
5/31/2006 6:23:50 PM
Hugo,

Thank you so much mate! Works perfectly. I was aware of temporary
tables I have just never used them before and didn't think of it as an
option. Thanks again.


[quoted text, click to view]
Re: Accessing stored proc multiple return values Hugo Kornelis
6/1/2006 12:35:35 AM
[quoted text, click to view]

Hi evs,

CREATE TABLE #tmp ( load_id -- datatype
, last_succ_load_id -- datatype
, datEventDate -- datatype
);
INSERT INTO #tmp (load_id, last_succ_load_id, datEventDate)
EXEC MY_SP @processname;
SELECT load_id, last_succ_load_id, datEventDate
FROM #tmp;
DROP TABLE #tmp;

--
AddThis Social Bookmark Button