Chapter 7. Error Handling

for RuBoard

Great designers aren't afraid of complexity, and some of the best are drawn to it. But their goal is to make the seemingly complex simple.

Steve McConnell [1]

[1] McConnell, Steve. After the Gold Rush . Redmond, WA: Microsoft Press, 1999. Page 26.

In this chapter we'll talk about the conventional ways of raising and handling errors in stored procedures, as well as some of the quirks you may run into with Transact-SQL error management. Transact-SQL's error-handling facilities work reasonably well, but they don't always work in the most logical fashion or as consistently as we might like. Even if you're careful to add error-handling code to every stored procedure on your server, you can't rely on it to work 100% of the time, even for low-severity errors. You must implement robust error handling in your client applications to complement the error handling in your Transact-SQL code. Microsoft has publicly announced that in the next version of SQL Server (code named Yukon), Transact-SQL will have structured exception-handling syntax built in. When this happens, you'll have better control over errors and unexpected conditions in your code. Until then, you may have to jump through a few hoops to get the error handling in your applications just right. That's what this chapter is aboutshowing you where the pitfalls are and giving you advice on how to avoid them.

for RuBoard


The Guru[ap]s Guide to SQL Server[tm] Stored Procedures, XML, and HTML
The Guru[ap]s Guide to SQL Server[tm] Stored Procedures, XML, and HTML
ISBN: 201700468
EAN: N/A
Year: 2005
Pages: 223

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net