• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 8. Designing SQL Server Stored P... > Errors and Error Handling

Errors and Error Handling

So far, the examples in this chapter have contained no error handling. This means that they leave what happens when an error occurs up to chance. Although T-SQL provides a means of handling errors, the error-handling model in T-SQL is not as powerful as that in VBA. Because there's no ON ERROR GOTO statement, you must handle errors as they occur.

Handling Runtime Errors

One alternative to handling errors as they occur is to prevent errors from occurring in the first place. The Orders table in the Northwind database requires that data be entered for the OrderID and RequiredDate fields. The OrderID field is an IDENTITY column, so this is not of concern. Here's the error that occurs if a value is not supplied for the required date field:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint