<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Search results matching tags 'SQL Server 2011', 'rethrow', 'CTP1', and 'denali'</title><link>http://sqlblog.com/search/SearchResults.aspx?o=DateDescending&amp;tag=SQL+Server+2011,rethrow,CTP1,denali&amp;orTags=0</link><description>Search results matching tags 'SQL Server 2011', 'rethrow', 'CTP1', and 'denali'</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>SQL Server v.Next (Denali) : Exploring THROW</title><link>http://sqlblog.com/blogs/aaron_bertrand/archive/2010/11/22/sql-server-v-next-denali-using-throw-instead-of-raiserror.aspx</link><pubDate>Mon, 22 Nov 2010 17:20:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:30385</guid><dc:creator>AaronBertrand</dc:creator><description>&lt;p&gt;Sadly, THROW is not mentioned on the &lt;a href="http://msdn.microsoft.com/en-us/library/cc645577%28v=SQL.110%29.aspx" title="http://msdn.microsoft.com/en-us/library/cc645577(v=SQL.110).aspx" target="_blank"&gt;Programmability Enhancements (Database Engine) topic&lt;/a&gt; of Denali's "What's New" section.&amp;nbsp; So, unless you were at PASS or have been reading the various blogs from the keynotes and other Denali sessions, the presence of this keyword may be news to you.&amp;nbsp; I wanted to touch briefly on what THROW can do and, more importantly, what it can't do - before you start thinking about abandoning all usage of RAISERROR (or "RAISE ROAR" as Tobias calls it).&lt;br&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;&lt;font size="4"&gt;How THROW and RAISERROR differ&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;THROW outside of a CATCH block acts similar to RAISERROR, with a few notable exceptions:&lt;br&gt;&lt;br&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The message_id parameter does not need to be defined in sys.messages:

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="blue"&gt;THROW&lt;/font&gt; 66666, &lt;font color="red"&gt;'Hi'&lt;/font&gt;, 1;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;

Result:

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;div style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="red"&gt;Msg 66666, Level 16, State 16, Line 1&lt;br&gt;Hi&lt;/font&gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;

With RAISERROR, you can use a string for the first parameter, but if you use a number that is not represented in sys.messages:

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="blue"&gt;RAISERROR&lt;/font&gt;(54321, 16, 1);&lt;br&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;

Result:

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;div style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="red"&gt;Msg 18054, Level 16, State 1, Line 1
&lt;br&gt;Error 54321, severity 16, state 1 was raised, but no message with that error number was found in sys.messages. If error is larger than 50000, make sure the user-defined message is added using sp_addmessage.&lt;/font&gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;

Why should you care?  Well, if you have applications that rely on certain error message numbers coming out of SQL Server (and ignore the text of the error message), converting to THROW will allow you to migrate to new servers without having to set up all of the messages in sys.messages.
&lt;br&gt;&lt;br&gt;&amp;nbsp;&lt;br&gt;&lt;/li&gt;


&lt;li&gt;The message_id parameter must be an INT (not a BIGINT) &amp;gt;= 50000.&amp;nbsp; If you try to THROW a system message, you will get an error message instead of the error you wanted:

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="blue"&gt;RAISERROR&lt;/font&gt;(14088, 16, 1, &lt;font color="red"&gt;N'foo'&lt;/font&gt;);&lt;br&gt;&lt;font color="blue"&gt;GO&lt;br&gt;THROW&lt;/font&gt; 14088, &lt;font color="red"&gt;N'foo'&lt;/font&gt;, 1;&lt;br&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;
 
Result:

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;div style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="red"&gt;Msg 14088, Level 16, State 1, Line 1&lt;br&gt;The table 'foo' must have a primary key to be published using the transaction-based method.&lt;br&gt;Msg 35100, Level 16, State 10, Line 1&lt;br&gt;Error number 14088 in the THROW statement is outside the valid range. Specify an error number in the valid range of 50000 to 2147483647.&lt;/font&gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;
&lt;br&gt;&amp;nbsp;
&lt;/li&gt;


&lt;li&gt;There is no token substitution within the command itself, so printf formatting is ignored.&amp;nbsp; Let's say we've added this message to sys.messages:

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="blue"&gt;EXEC&lt;/font&gt; &lt;font color="#aa0000"&gt;sys&lt;/font&gt;.&lt;font color="#aa0000"&gt;sp_addmessage&lt;/font&gt; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @msgnum   = 66667,&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @severity = 16,&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @msgtext  = &lt;font color="red"&gt;N'There is already a %s named %s.'&lt;/font&gt;;&lt;br&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;

With RAISERROR we can simply say:

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="blue"&gt;RAISERROR&lt;/font&gt;(66667, 16, 1, &lt;font color="red"&gt;N'foo'&lt;/font&gt;, &lt;font color="red"&gt;N'bar'&lt;/font&gt;);&lt;br&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;

Result:

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;div style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="red"&gt;Msg 66667, Level 16, State 1, Line 1&lt;br&gt;There is already a foo named bar.
&lt;/font&gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;

However, THROW does not accept any parameters for substitution.&amp;nbsp; If you try:

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="blue"&gt;THROW&lt;/font&gt; 66667, &lt;font color="red"&gt;N'There is already a %s named %s.'&lt;/font&gt;, 1, &lt;font color="red"&gt;N'foo'&lt;/font&gt;, &lt;font color="red"&gt;N'bar'&lt;/font&gt;;&lt;br&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;

Result:

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;div style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="red"&gt;Msg 102, Level 15, State 1, Line 1&lt;br&gt;Incorrect syntax near ','.
&lt;/font&gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;

Since repeating the text defeats the purpose of saving the error message in sys.messages in the first place, you can get around this using FORMATMESSAGE():

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="blue"&gt;DECLARE&lt;/font&gt; @msg &lt;font color="blue"&gt;NVARCHAR&lt;/font&gt;(2048) = &lt;font color="magenta"&gt;FORMATMESSAGE&lt;/font&gt;(66667, &lt;font color="red"&gt;N'foo'&lt;/font&gt;, &lt;font color="red"&gt;N'bar'&lt;/font&gt;);&lt;br&gt;&lt;font color="blue"&gt;THROW&lt;/font&gt; 66667, @msg, 1;&lt;br&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;

Result:

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;div style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="red"&gt;Msg 66667, Level 16, State 1, Line 2&lt;br&gt;There is already a foo named bar.&lt;/font&gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;

Cumbersome, but it works.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;/li&gt;

&lt;li&gt;The severity level for THROW is always 16 (unless it is a re-throw inside CATCH), and there is no way to force the breaking of the connection like we can with RAISERROR.&amp;nbsp; Assume we have added this error message:

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="blue"&gt;EXEC&lt;/font&gt; &lt;font color="#aa0000"&gt;sys&lt;/font&gt;.&lt;font color="#aa0000"&gt;sp_addmessage&lt;/font&gt; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @msgnum&amp;nbsp;&amp;nbsp; = 66668,&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @severity = 24,&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @msgtext&amp;nbsp; = &lt;font color="red"&gt;N'This is really bad.'&lt;/font&gt;;&lt;br&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;

If we use RAISERROR, we can obey the severity level by re-specifying and using WITH LOG:

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="blue"&gt;RAISERROR&lt;/font&gt;(66668, 24, 1) &lt;font color="blue"&gt;WITH LOG&lt;/font&gt;;&lt;br&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;

Result:

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;div style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="red"&gt;Msg 2745, Level 16, State 2, Line 1&lt;br&gt;Process ID 55 has raised user error 66668, severity 24. SQL Server is terminating this process.&lt;br&gt;Msg 2745, Level 16, State 2, Line 1&lt;br&gt;Process ID 55 has raised user error 66668, severity 24. SQL Server is terminating this process.&lt;br&gt;Msg 66668, Level 24, State 1, Line 1&lt;br&gt;This is really bad.&lt;br&gt;Msg 0, Level 20, State 0, Line 0&lt;br&gt;A severe error occurred on the current command.&amp;nbsp; The results, if any, should be discarded.&lt;/font&gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;

There is no way to do that with THROW:

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="blue"&gt;THROW&lt;/font&gt; 66668, &lt;font color="red"&gt;N'This is really bad.'&lt;/font&gt;, 1;&lt;br&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;

Result:

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;div style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="red"&gt;Msg 66668, &lt;b&gt;Level 16&lt;/b&gt;, State 1, Line 1&lt;br&gt;This is really bad.&lt;/font&gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;
&lt;br&gt;&amp;nbsp;
&lt;/li&gt;

&lt;li&gt;There is no THROW equivalent to WITH NOWAIT for immediate buffer output.&amp;nbsp; With RAISERROR we can do this:

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="blue"&gt;RAISERROR&lt;/font&gt;(&lt;font color="red"&gt;N'Printing status...'&lt;/font&gt;, 0, 1) &lt;font color="blue"&gt;WITH NOWAIT&lt;/font&gt;;&lt;br&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;

This can be quite useful in place of PRINT when monitoring a query with multiple steps, as it prevents waiting for the buffer to fill up before seeing real-time messages in the results pane of Management Studio.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;/li&gt;

&lt;li&gt;Unlike RAISERROR, THROW honors XACT_ABORT (see &lt;a href="http://www.nielsberglund.com/sql/more-t-sql-error-functionality-in-denali-sql-11/" title="http://www.nielsberglund.com/sql/more-t-sql-error-functionality-in-denali-sql-11/" target="_blank"&gt;Neils Berglund's post&lt;/a&gt; for more information).&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;/li&gt;

&lt;li&gt;There is no way to use WITH LOG in combination with THROW, or to "THROW" a non-severe error (e.g. one that prints in black in Management Studio instead of red, like the above example with severity level 0).&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;&lt;font size="4"&gt;THROW inside CATCH&lt;br&gt;&lt;/font&gt;
&lt;p&gt;THROW inside a CATCH block acts like RETHROW - it will re-raise the exception that transferred to the CATCH block in the first place.&amp;nbsp; An example:&lt;/p&gt;

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="blue"&gt;BEGIN TRY&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RAISERROR&lt;/font&gt;(&lt;font color="red"&gt;N'Hi from try.'&lt;/font&gt;, 16, 1);&lt;br&gt;&lt;font color="blue"&gt;END TRY&lt;br&gt;BEGIN CATCH&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PRINT&lt;/font&gt; &lt;font color="red"&gt;N'Hi from inside CATCH.'&lt;/font&gt;;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="blue"&gt;THROW&lt;/font&gt;;&lt;br&gt;&lt;font color="blue"&gt;END CATCH&lt;/font&gt;
&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;

This will allow you to perform other tasks, such as rollbacks, notifications, etc. before eventually throwing the same errors back to the caller - without having to understand and re-code all of the possible outcomes from within the TRY block.&amp;nbsp; Note that THROW inside CATCH can re-throw multiple errors, not just the most recent one (which is all you have access to from ERROR_MESSAGE() and its cousins).&amp;nbsp; And this is the only place where THROW by itself is valid syntax.&lt;br&gt;

&lt;p&gt;I am not going to pretend to be an expert in error handling, so I will leave it up to Erland to give you a great primer:&lt;/p&gt;

&lt;blockquote&gt;&lt;a href="http://www.sommarskog.se/error_handling_2005.html" title="http://www.sommarskog.se/error_handling_2005.html" target="_blank"&gt;Error Handling in SQL 2005 and Later&lt;/a&gt;&lt;br&gt;&lt;/blockquote&gt;

&lt;p&gt;&lt;br&gt;&lt;font size="4"&gt;A few more items to consider&lt;/font&gt; &lt;br&gt;&lt;/p&gt;

&lt;p&gt;Note that THROW() is one more case where the preceding statement needs to end with a proper statement terminator.&amp;nbsp; So just as a gentle reminder, &lt;a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2009/09/03/ladies-and-gentlemen-start-your-semi-colons.aspx" title="http://sqlblog.com/blogs/aaron_bertrand/archive/2009/09/03/ladies-and-gentlemen-start-your-semi-colons.aspx" target="_blank"&gt;start using those semi-colons&lt;/a&gt;! &lt;/p&gt;

&lt;p&gt;Also note that there is still a very noticeable omission in the TRY/CATCH error handling model: FINALLY. &lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;font size="4"&gt;And finally (no pun intended), some housekeeping&lt;/font&gt; &lt;br&gt;&lt;/p&gt;

&lt;p&gt;The current version of Denali's Books Online indicates that RAISERROR is deprecated.&amp;nbsp; From the RAISERROR (Transact-SQL) topic (&lt;a href="http://msdn.microsoft.com/en-us/library/ms178592%28SQL.110%29.aspx" title="http://msdn.microsoft.com/en-us/library/ms178592(SQL.110).aspx" target="_blank"&gt;http://msdn.microsoft.com/en-us/library/ms178592(SQL.110).aspx&lt;/a&gt;):&amp;nbsp; &lt;/p&gt;

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;div style="padding:10px 20px;font-size:12px;font-family:georgia,times new roman;-moz-background-inline-policy:continuous;"&gt;&lt;i&gt;
This feature will be removed in a future version of Microsoft SQL 
Server. Avoid using this feature in new development work, and plan to 
modify applications that currently use this feature. New applications 
should use &lt;a href="http://msdn.microsoft.com/en-us/library/ee677615%28v=SQL.110%29.aspx"&gt;THROW&lt;/a&gt; instead.&lt;/i&gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;

&lt;p&gt;Books Online is currently incorrect, and should be updated soon.&amp;nbsp; There is currently no publicized plan to remove RAISERROR; what the topic should state is that only the old-style RAISERROR is deprecated, e.g.:&lt;/p&gt;

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="blue"&gt;RAISERROR&lt;/font&gt; 54321 &lt;font color="red"&gt;N'This is an old-style RAISERROR.'&lt;/font&gt;;&lt;br&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;

&lt;p&gt;Of course you can still use this syntax today, but it has been on the deprecation path for some time.  If you run the above code on Denali, SQL Server 2008 R2 or even SQL Server 2008, you will see this performance counter increase:&lt;/p&gt;

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="blue"&gt;SELECT&lt;/font&gt; [object_name], instance_name, cntr_value&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="blue"&gt;FROM&lt;/font&gt; &lt;font color="green"&gt;sys&lt;/font&gt;.&lt;font color="green"&gt;dm_os_performance_counters&lt;/font&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="blue"&gt;WHERE&lt;/font&gt; [object_name] &lt;font color="grey"&gt;LIKE&lt;/font&gt; &lt;font color="red"&gt;N'%:Deprecated Features%'&lt;/font&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="grey"&gt;AND&lt;/font&gt; instance_name = &lt;font color="red"&gt;N'Oldstyle RAISERROR'&lt;/font&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="grey"&gt;AND&lt;/font&gt; cntr_value &amp;gt; 0;&lt;br&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;
&lt;br&gt;&amp;nbsp;
</description></item></channel></rss>