468,545 Members | 1,853 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,545 developers. It's quick & easy.

return val of stored procedure in query analyzer

hi ng,

i am newbie to sqlserver and my problem seems simple, but i didn't find
information about it:
How can i display the
RETURN @x
value of a stored procedure in the sql analyzer of the sqlserver?
thanks a lot,
d
Jul 20 '05 #1
2 3130
Daniel wrote:
hi ng,

i am newbie to sqlserver and my problem seems simple, but i didn't find
information about it:
How can i display the
RETURN @x
value of a stored procedure in the sql analyzer of the sqlserver?
thanks a lot,
d


i just realized that the return value of my stored procedure with
inserts is the number of datasets inserted, even if i write

DECLARE @i int
set @i=9
RETURN @i

so, the question is: is it possible to return i to the invoking application?
thanks
d
Jul 20 '05 #2
Hi Daniel,

One approach that I use is to create a temp table in the stored procedure.
For example: Create a table with fields ID as IDENTITY and Message as a
varchar(1000). Temp tables have a prefix of # for example, #Message.

Then as the Stored Procedure executes, you can INSERT into Message whatever
messages you want. You can return row counts, all kinds of stuff re the
#Message table. This is extreamly helpful for long stored procedures.

At the end of the Stored Proc, do the following:

Select Message from #Message.

This will return all the rows to the calling program if you have opened up
the call to the stored proc as returning a recordset.

Then at the end of the stored procedure, just drop the temp table.

Drop Table #Message.

Hope this helps.

Barry




"Daniel" <da**********@zdv.uni-tuebingen.de> wrote in message
news:cl**********@newsserv.zdv.uni-tuebingen.de...
Daniel wrote:
hi ng,

i am newbie to sqlserver and my problem seems simple, but i didn't find
information about it:
How can i display the
RETURN @x
value of a stored procedure in the sql analyzer of the sqlserver?
thanks a lot,
d


i just realized that the return value of my stored procedure with inserts
is the number of datasets inserted, even if i write

DECLARE @i int
set @i=9
RETURN @i

so, the question is: is it possible to return i to the invoking
application?
thanks
d

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by vikram.mankar | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by UniDue | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.