Suppressing Error messages in SP

  • Hi

    I need to update my table based on many condition. For this I have created many update SP's, each one updating the table for one condition. I have a table configured for these SPs, in which the order of execution and the SP name present.

    Now I have created a Master SP that will fetch the SP name from this configuration table and execute them one by one using cursor. If the update is successful, the update SP's will return '0' else the error code. If the Error code is returned, then it has to be updated into an Error table and rollback the transaction.

    Now I have 2 issues

    1. While there is an error, its returning the Error code and the Error message. I want to suppress the Error message, I need only the Error code. How to do this ?

    2. I don't want to log all these transactions. How to make my query so that i does not log this operation ?

    Thanks

     

  • 1)

    There are different kinds of errors, with different behaviour regarding to what you can and can't catch within a stored procedure. Do you have an example of an error (with text) showing what you want to do..?

    2)

    Do you mean 'not log' as in 'not write to the transaction log'?

    There is no way to 'turn off' writing to the tran log.

    /Kenneth

  • like Ken said, if the error is level 16 or above, (foreign key constraint,unique constraint, primary key for example) it cannot be capture via TSQL.

    use a different style of logic to work around; ie test for the offending condition before doing any work

    if not exists(select childkey from sometable where otherkey in(select other key from master table) )

    begin

    delete from sometable where otherkey in(select other key from master table) )

    end

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

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

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