Updated on Kisan Patel
This tutorial will show you how to catch and throw error in SQL Server?
To throw error, we use RAISERROR
statement.
BEGIN TRY SELECT 'csharpcode'/1 END TRY BEGIN CATCH PRINT 'In catch block.'; RAISERROR ('Error' --Message Text ,16 --Severity ,1 --State) END CATCH
Here, notice the BEGIN CATCH block that uses RAISERROR
statement to throw the error.