New Statement THROW (Transact-SQL) SQL Server 2012


Throw introduces a new way to raise an exception in CATCH block of a TRY…CATCH construct in SQL Server 2012.

The syntax is:
THROW [ { error_number | @local_variable },
        { message | @local_variable },
    { state | @local_variable }
] [ ; ]

If you use THROW outside the Try … Catch block,
you must use parameters (You don’t have to if you use it within the Catch block.

The differences between the RAISERROR and THROW statements are:

1.The error_number parameter does not have to be defined in sys.messages.
2.The message parameter does not accept printf style formatting.
3.There is no severity parameter. The exception severity is always set to 16.

More Information and examples:
http://msdn.microsoft.com/en-us/library/ee677615(v=sql.110).aspx

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s