seting a variale while a stored procedure is run

  • Hi

    I have a local variable

    Declare @ret int

    and I have a stored procedure

    that simply selects the sum of expense named as sp_SumTolat

    I am trying this :

    Set @ret = exec sp_SumTolat

    This is not working could anyone please guide me as to what should i be doing?

  • Does your stored proc have an output parameter? If not, add one in the code to output the sum. Then execute as follows:

    Declare @ret int

    exec sp_SumTolat @ret output

    select @ret

  • thanks for the help.

    This is exactly what I required.

  • Asking as a Newbie, with no offence intended, wouldn't a function serve a better purpose to do the same thing?


    Regards,

    goodguy

    Experience is a bad teacher whose exams precede its lessons

  • its nice that you asked.

    Basically I was trying this first with a function but then found out that I cannot access a linked server from within a function.

    So I had to take this stored procedure as an alternate.

    Can i call a stored proceduere from within a function?

    or can i call a databse in another server ?

    or can i use open query in a function ?

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply