How to set value of procedure to variable?

  • Hello mates.

    I want to create a procedure with follow two sentences.

    DECLARE @Wallet int

    SET @Wallet = EXEC HowMoneyIsInTheWallet @IDOsoby

    And I have this error: Incorrect syntax near the keyword 'EXEC'.

    How resolve the problem ?

  • Hi sasia

    you need to define output parameter to your procedure

    for example

    create procedure HowMoneyIsInTheWallet

    (

    @IDOsoby int,

    @Wallet int OUTPUT

    )

    AS

    -- your code where you set value to @Wallet

    return @Wallet

    call the stored procedure

    DECLARE @WalletReturned int, @Wallet int

    EXEC @WalletReturned = HowMoneyIsInTheWallet @IDOsoby, @Wallet output

    print @WalletReturned

  • Thank you SrcName for your answer.

    You help me, and i am thankfull you for that 🙂

    I wish you have a nice day 😀

    Enjoy 🙂

Viewing 3 posts - 1 through 2 (of 2 total)

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