[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

sql server 2012 - THROW

Posted on 2013-05-14
1
Medium Priority
?
307 Views
Last Modified: 2013-05-14
BEGIN TRY
      --do something wrong
      SELECT 100/0 AS 'Problem';
END TRY
BEGIN CATCH
      PRINT 'Code inside CATCH is beginning'
      PRINT 'Error: ' + CAST(ERROR_NUMBER() AS VARCHAR(255));
      THROW;
END CATCH

Hi experts,
I do not understand the THROW. In that scenario is useful
0
Comment
Question by:enrique_aeo
1 Comment
 
LVL 33

Accepted Solution

by:
knightEknight earned 1000 total points
ID: 39166899
The THROW command will simply re-throw the same error that was caught.  It would be equivalent (in SQL 2005/2008) to using raiserror with the "caught" error message, level, state, etc.

If you don't throw the error in the catch, then the batch will continue after the end-catch.

http://www.sqlservercentral.com/blogs/sql-development-wizard/2012/05/31/a-new-neat-feature-in-sql-server-2012-is-throw/
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Screencast - Getting to Know the Pipeline

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question