Solved

sql server 2012 - THROW

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

839 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