1USE tempdb;
2GO
3CREATE TABLE dbo.TestRethrow
4( ID INT PRIMARY KEY
5);
6BEGIN TRY
7 INSERT dbo.TestRethrow(ID) VALUES(1);
8-- Force error 2627, Violation of PRIMARY KEY constraint to be raised.
9 INSERT dbo.TestRethrow(ID) VALUES(1);
10END TRY
11BEGIN CATCH
12
13 PRINT 'In catch block.';
14 THROW;
15END CATCH;
16
17