Options

SQL Prompt - strange behavior with ROLLBACK TRANSACTION

Hello,

in my stored procedures I often use the pattern
IF @somecindition = TRUE
BEGIN
  COMMIT TRANSACTION;
END;
ELSE BEGIN
ROLLBACK TRANSACTION;
END;</code>IF @somecondition = TRUE
BEGIN
  COMMIT TRANSACTION;
END;
ELSE 
BEGIN
  ROLLBACK TRANSACTION;
END;</pre><div>When I use SQL Prompt to format this code, the COMMIT TRANSACTION statement is correctly indented (as being in a BEGIN END block), but the ROLLBACK TRANSACTION always ends up in the first column, regardles of the depth of BEGIN/END blocks it is in, like this:<br><br></div><pre class="CodeBlock"><code>
Why is this, and how can I force SQL Prompt to indent ROLLBACK as it does with COMMIT?

Answers

  • Options

    Hi @Guenter

     

    Thank you for reaching out on the Redgate forums regarding your SQL Prompt formatting.

     

    Unfortunately, the formatting of your code in your post appears to be mixed up and isn't clearly identifying your request.

     

    Are you able to provide a screenshot of your snippet pre- & post-formatting, so we can better understand what is occurring

    My initial area of investigation would be the Control Flow section of your Style formatting. Modifying settings here does affect the spacing & positioning of Begin/End blocks

     

     

    If you can provide a screenshot of what is occurring in your formatting, it would be helpful for us to better determine the formatting style setting change that may help solve your inquiry.

    Jon Kirkwood | Technical Support Engineer | Redgate Software
  • Options
    GuenterGuenter Posts: 12 Bronze 1

    Hi Jan,

    thank you for your post. If the formatting output on my computer were as you show it, I'd be really happy.
    But my output looks different:



  • Options
    GuenterGuenter Posts: 12 Bronze 1
    After looking at it, the difference seems to come from the option "Collapse statements shorter than 40 characters". When I toggle this setting, the formatting gets right - so maybe it's just a glitch in the shortening formatter?
Sign In or Register to comment.