Terminate SP

  • How do I terminate an SP if a particularly field does not exist in the table I am field the SP on.

    i.e.

    Create Proc xxx

    --check if column exists in table

    --If doesn't exist, terminate SP and display error message

    Else

    Continue with SP

     

    Thanks in advance..

  • You can used a RETURN STATEMENT anywhere in your stored procedure to exits from SP.

     

    There is a RAISEERROR statement to generate the error which you want to display like

    RAISERROR ('Field not exists .', 16, 1)

     

    cheers

  • rao's solution is the best.

    if (x = y)

    raiserror ()

    return

    else

    -- continue

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

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