THROW
torsten.strauss
Posts: 271 Silver 3
in SQL Prompt
Hi Redgate Team!
SQL Prompt will format the following statement
SQL Prompt will format the following statement
BEGIN TRY
RAISERROR('test', 16, 1);
END TRY
BEGIN CATCH
SELECT 1
THROW
END CATCH;
like this
like this
BEGIN TRY
RAISERROR('test', 16, 1);
END TRY
BEGIN CATCH
SELECT 1 THROW;
END CATCH;
Which is wrong - instead it should be formatted like
Which is wrong - instead it should be formatted like
BEGIN TRY
RAISERROR('test', 16, 1);
END TRY
BEGIN CATCH
SELECT 1;
THROW;
END CATCH;
Thanks for fixing it!
Torsten
Thanks for fixing it!
Torsten
Tagged:
Answers
If we run the original script you provided to us without formatting with SQL Prompt, the result in SSMS is a table with column THROW and a value of 1. If we then run the same script with SQL Prompt formatting, we get the same result in SSMS.
If we run the formatted script (adding the semicolon / new line before THROW), the result in SSMS is "Msg 50000, Level 16, State 1, Line 2 test", which is correct for the formatted script.
Dan Jary | Redgate Software
Have you visited our Help Center?
thanks for your reply!
Dan Jary | Redgate Software
Have you visited our Help Center?