Solved

sql server 2012 - THROW

Posted on 2013-05-14
1
286 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 250 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now