My favorite feature in Denali. Well one of…

Only because I've been waiting for it since I first saw try-catch back in 2005 beta 2 or something. In dirt-simple code:

begin try
  delete jobs
end try
begin catch
  throw
end catch

Nuff said. Error 547 is sooooo much more backward compatible than error 50000. Realize that, if throw is preceeded by another statement (begin catch is part of the codeblock, not a statement), the preceeding statement must end with a semicolon (you were putting in those semicolons when they were almost always optional, weren't you?):

begin try
delete jobs
end try
begin catch
print 'in catch block';
throw
end catch

Finally, all we need is a finally block. Well, maybe they could go all the way with ANSI SQL standard error handling. Some day. But it would have to be combined with a backward-compat switch. Maybe at a database level or something.

Other articles

Imagine feeling confident enough to handle whatever your database throws at you.

With training and consulting from SQLskills, you’ll be able to solve big problems, elevate your team’s capacity, and take control of your data career.