storing output of a Stored Procedure in a vairable

  • Hi,

    I am inserting value in a table Gv_storeAllocation for column STNNo i have created a stored procedure.

    Can anyone tell me how to store output of that stored procedure in a variable @StnNo?

    INSERT INTO GV_StoreAllocation (StoreId, STNNo, FirstVoucherNo, LastVoucherNo, Quantity)

    SELECT

    DISTINCT @storecode,

    EXEC @STNNo = dbo.GetSTNValue @storecode , 0 ,'',

    @FirstVoucherID,

    @lastvoucherID,

    @quantity

    FROM GV_Voucher gv

    JOIN GV_VoucherStatus gvs ON gv.VoucherStatusId = gvs.VoucherStatusId

    WHERE gvs.VoucherStatus = 'Active at HO

    _______________________________________________________________
    To get quick answer follow this link:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • yess I can do it 🙂

    _______________________________________________________________
    To get quick answer follow this link:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • please share

  • aaron.reese (4/24/2013)


    please share

    Declare @STNno varchar(10)

    EXEC dbo.GetSTNValue @storecode , 0 ,@stnno OUT

    INSERT INTO GV_StoreAllocation (StoreId, STNNo, FirstVoucherNo, LastVoucherNo, Quantity)

    SELECT

    DISTINCT @storecode,

    @STNno,

    @FirstVoucherID,

    @lastvoucherID,

    @quantity

    FROM GV_Voucher gv

    JOIN GV_VoucherStatus gvs ON gv.VoucherStatusId = gvs.VoucherStatusId

    WHERE gvs.VoucherStatus = 'Active at HO

    _______________________________________________________________
    To get quick answer follow this link:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

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

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