• dhechle (4/30/2014)


    I have always believed best practice when writing stored procedures or any SQL code is to include error handling. I was challenged today though as to why include error handling in a certain ETL project being written at the moment, I think its quite obvious that if there is some sort of failure then the load should roll back instead of leaving it in a non consistent state.

    I was then asked as to what scenarios might a failure occur, there is the obvious of network blips, servers failing, databases failing, deadlocks occurring, table being accidentally dropped, can you think of any specific reasons as to why you have used error handling in any projects and when it has provided useful.

    thanks in advance.

    Well gosh...you are talking an ETL process. That means it is an automatic process right? Wouldn't business like to be informed if something didn't work? Let's say your scenarios of a table being dropped happened. If you didn't have error handling how long would the process keep crashing before somebody noticed?

    What a strange challenge. This is like asking "why do you have car insurance?" or "why do you wear a seatbelt?". 99.99999% of the time it isn't necessary, but that one time when the "OH S..." happens it is better to be prepared by being able to handle the issue instead of just crashing.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/