THROW

Hi Redgate Team!
SQL Prompt will format the following statement 
BEGIN TRY
RAISERROR('test', 16, 1);
END TRY
BEGIN CATCH
SELECT 1
THROW
END CATCH;

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

BEGIN TRY
RAISERROR('test', 16, 1);
END TRY
BEGIN CATCH
SELECT 1;
THROW;
END CATCH;

Thanks for fixing it!

Torsten

Answers

  • Hi @torsten.strauss

    Thanks for raising this. We've managed to reproduce the issue as well and will be escalating to our development team for review. We'll get back to you with further instructions. Sorry for any inconvenience.

    Kind regards,

    Pete Ruiz

  • Hi @torsten.strauss

    Our sincerest apology for the delay in responding to you regarding this!

    Our development team have now taken a look at this and they have fed back that they do not believe this is a bug. 

    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.

    I hope this helps, however please don't hesitate in reaching out to us again if you have any further questions regarding this.


    Kind regards

    Dan Jary | Redgate Software
    Have you visited our Help Center?
  • Hi Dan,

    thanks for your reply!
    You are right, but SQL Prompt provides the functionality to add semicolons when it makes sense.
    So the formatting of the code should automatically add a semicolon before THROW (and before WITH cte). Otherwise, I once question the usefulness of the "adding semicolons" feature.
  • Hi @torsten.strauss

    My apology for the delay in acknowledging your last update on this post!

    Thanks for highlighting this to us, we appreciate your feedback/help regarding this! I will relay this back to the team here and update you with any progress updates going forward.
    Kind regards

    Dan Jary | Redgate Software
    Have you visited our Help Center?
  • Thanks Dan!
Sign In or Register to comment.