locked
Need help with stored procedure RRS feed

  • Question

  • User100706074 posted

    HI,

    Table Name Images

    ReceiptNumber nvarchar(10)

    Image1 nvarchar(50)

    Image2 nvarchar(50)

    Image3 nvarchar(50)

    Image4 nvarchar(50)

    i need to write a stored procedure which will accomplish the following

    Parameters @Image , @Receiptno

    The stored procedure must first check for a Null value in Image1 and if value is null then insert @Image in Image1 where ReceiptNumber is @Receiptno . If Image1 is not null then @Image must be inserted in Image2 and so on.

    Finally if all the 4 Image fields are full then it should return some error.

    Any ideas on this?

    Sunday, June 10, 2012 3:12 PM

Answers

  • User-661350001 posted

    Declare IsError INT = 0

    If Exists(Select 1 From Images(NOLOCK) Where Image1 IS NOT NULL AND Image2 Is not Null AND Image3 Is Not Null AND IMAGE4 IS not null And ReceiptNumber = @Receiptno)

    --RaiseError ''

    Return -1

    similarly check for each column and insert

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, June 10, 2012 3:58 PM