By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,262 Members | 1,125 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,262 IT Pros & Developers. It's quick & easy.

return val of stored procedure in query analyzer

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.