The THROW Statement in SQL Server 2014

The THROW statement includes parameters to define a user-defined error. Alternatively, in a
CATCH block you can use THROW without parameters to re-throw the original error.
This code sample shows how to use the THROW keyword to throw a custom exception.
Using the THROW statement
CREATE PROCEDURE GetCustomerDetails @CustomerKey int
AS
SELECT * FROM Customers WHERE CustomerKey = @CustomerKey
IF @@ROWCOUNT = 0
THROW 50001, ‘Customer does not exist’, 1
The THROW Statement in SQL Server 2014
Reviewed by Unknown
on
12:04 AM
Rating:

No comments: