Error Handling - String or binary data would be truncated

  • Hi all,

    We have a wrapper procedure that i am looking at replacing shortly. Basic Layout is something like like

    Create proc SP_Wrapper

    as

    SP_LogProc 'proc1','Start'

    Exec proc1

    SP_LogProc 'proc1','End'

    SP_LogProc 'proc2','Start'

    Exec proc2

    SP_LogProc 'proc2','End'

    SP_LogProc 'proc3','Start'

    Exec proc3

    SP_LogProc 'proc3','End'

    ....

    You get the idea. So logproc just logs that the procedure has started or stopped to a table so we can monitor it easily.

    The procedure is then run by an agent job every morning. This morning we had a little bit of an odd one. In the example above we effectively got to 'proc3' being started (as it was logged). However there was then an error of String or binary data would be truncated (severity 16 i believe). However when proc3 was then manually run it worked (the data was unchanged). Then going back proc2 works fine, and its actually proc1 that has the error.

    I have looked through the procs in question (and the wrapper) and cant find any error handling that is relevent (there one try and catch block completely separate at the end of the wrapper procedure for a small routine).

    Why would it continue on? Reading online someone has put that some errors will fail blocks of code rather than individual elements. Is this true? Could this be whats causing this?

    Many thanks,

    Dan

  • You could wrap the executions in a try/catch and/or check the @@ERROR to catch the error when and where it happens.

    😎

  • Amongst quite a few other additions that will be the plan.

    What I am trying to understand is why what has happened, happened? It just seems a little odd to me.

  • Is there any error handling in SP_LogProc?

    😎

  • Eirikur Eiriksson (5/16/2014)


    Is there any error handling in SP_LogProc?

    😎

    Nope :crazy:

    Thanks anyway.

  • danielfountain (5/16/2014)


    Eirikur Eiriksson (5/16/2014)


    Is there any error handling in SP_LogProc?

    😎

    Nope :crazy:

    Thanks anyway.

    if the PROC2 is depends on the the successful execution of PROC1 then you need to use

    SET XACT_ABORT

    otherwise you can place individual TRY CATCH on each.

Viewing 6 posts - 1 through 5 (of 5 total)

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