Tracking errors in Stored Procedures

  • Using examples off the Internet I have managed to build a DTS package which loops through a number of countries. Then calls procedures to extract Excel Spreadsheets and then zip them. I am wondering the best way to trap errors in the procedures. For example I have the following code: DECLARE @ReturnStatus int - EXEC @ReturnStatus = procTest 'C:\Temdffp\Test.txt', 'C:\Temp\Test.zip' - IF @ReturnStatus <> 0 - I would like to add an entry in a table or perhaps send an SMTP email and exit the loop.

  • Hi, perhaps you can use 'xp_logevent' to generate an entry in the Sql Log file or the Windows Event Viewer ?. Regards, j.

  • Sorry, I did not make myself clear.

    If I have the following code in a DTS SQL Task

    DECLARE @ReturnStatus int

    Exec @ReturnStatus = procZipFilePassword 'InFileNameAndPath', 'OutFileNameAndPath', 'MyPassword'

    IF @ReturnStatus <> 0

    I want to put a row in a table and exit the package without continuing the loop. I don't want an entry in the SQL Log File not the Windows Event Viewer.

  • I think I stumbled across a solution. Would the way to do this be to use an output parameter to update a global variable. And then check this variable in the ActiveX script which controls the looping back.

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

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