![]() ![]() In chapter six I discuss special contexts where the rules are altered one way or another. Then we come to chapter five which is the centrepiece of this article: I attempt to classify errors from the different actions SQL Server may take in case of an error. In chapter three, I cover the basics for transactions in SQL Server and in chapter four I cover statements that one way or another are related to error handling. In the first chapter after this introduction I look at the components of an error message. This article aims at guiding the reader through this maze. And changing the behaviour to be more consistent is difficult, because there is a distinct risk that it would break existing applications. But Microsoft cannot only blame Sybase rather they have made the mess worse and worse through the years. What Microsoft inherited from Sybase was nothing Sybase should be proud of. When they plan for a new release they ask each other what can we do this time to confuse the users? Sometimes they run a little out of ideas, but then someone says Let's do something with error handling! On a more serious note, there is a lot of legacy. Every once in a while, I get the feeling that SQL Server is intentionally designed to be as confusing as possible. However, once you peel below the surface you find a confusing world of inconsistencies and limitations, which becomes even more bewildering when you look at what happens if the error occurs inside a transaction. In Part One, we learnt that SQL Server has TRY-CATCH, and given how things were in SQL 2000, TRY-CATCH is a great improvement. If you arrived directly to this article from elsewhere on the web, I recommend that you read Part One first, since the examples in this article make use of error_handler_sp which I introduce in the jumpstart article. Parts Two and Three are also considerably longer. In contrast, Parts Two and Three and the appendixes assume that you have some general programming experience, although necessarily not with SQL Server. Part One was intended for everyone, including the very unexperienced reader. In addition to the three main parts, there are three appendixes that discuss special topics: linked servers, the CLR and Service Broker respectively. In Part Three, I use this knowledge as a base for a discussion on how we should implement error handling in SQL Server in different situations. ![]() On the other hand, the focus of this part is exactly that: a detailed description of the commands for error and transaction handling and what can happen when an error occurs during the execution of a stored procedure or similar. The purpose of the first article was to give you a jumpstart on error handling without going into the very many details of error handling in SQL Server. This article is the second in a series of three about error and transaction handling in SQL Server. See here for font conventions used in this article. Error and Transaction Handling in SQL Server Part Two Error and Transaction Handling in SQL ServerĪn SQL text by Erland Sommarskog, SQL Server MVP. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |