I have this stored procedure and I can’t use Throw or RAISEERROR for some reason. I have to say I am a newbie in SQL Server, I have never used this statements before, but for some reason when I type them in doesn’t turn blue.
ALTER PROCEDURE [dbo].[del_pay_plan_proc]
@id INT
AS
BEGIN TRANSACTION
BEGIN TRY
DELETE FROM test_table WHERE [Id] = @id;
COMMIT TRANSACTION;
END TRY
BEGIN CATCH
THROW
END CATCH
I am using SQL Server 2008 R2.
What can be the reason that I can’t call the function RAISEERROR or use THROW statement?
Thanks in advance!
As per my understanding it should be like below…
By doing this, it is not required to throw any Exception if an error occurs. Control will automatically move inside Catch block in case any error occurs.
Reference from here