SQL Formatter Options

Stored Proc Conditions

The IF and Conditions Options in the SQL Formatter Tool allow you to customize the formatting of conditional statements (IF, THEN, ELSE) and related constructs. These settings ensure that conditions are formatted clearly and consistently, enhancing readability and maintainability.

Sql Formatter Options Stored Proc Conditions

IF and THEN/ELSE Formatting

  1. IF

    • Adds a line break before or after the IF keyword to structure conditional statements.
  2. THEN

    • Adds a line break before or after the THEN keyword for better separation.
    • Indent THEN: Indents the THEN block to align it hierarchically with the IF statement.
  3. After ELSE

    • Adds a line break after the ELSE keyword to clearly separate it from subsequent content.
    • Indent ELSE: Indents the ELSE block for better visual structure.

Conditions

  1. Open „(“ / Close „)“

    • Open „(„: Adds a line break before the opening parenthesis in conditions.
    • Close „)“: Adds a line break after the closing parenthesis for improved readability.
  2. AND/OR

    • Adds a line break before logical operators (AND/OR) in conditional statements for clarity.
  3. Indent Conditions in Brackets

    • Indents conditions enclosed within parentheses to align them with the surrounding structure.
  4. Align Compare Operators (<, >, =, …)

    • Aligns comparison operators (e.g., <, >, =) to create a clean and visually consistent layout.

BEGIN/END

  1. Indent BEGIN … END
    • Indents the BEGIN and END blocks to reflect the nested structure of procedural SQL.
    • This ensures that all statements within the block are visually grouped.

How to Use These Settings

  1. Enable Line Breaks for Keywords

    • Use the checkboxes for IF, THEN, and ELSE to define where line breaks are added around these keywords.
  2. Customize Indentation

    • Enable Indent THEN and Indent ELSE to structure the blocks for hierarchical alignment.
    • Use Indent Conditions in Brackets to format conditions neatly within parentheses.
  3. Control Parenthesis and Logical Operators

    • Use Open „(„ and Close „)“ to separate parenthesis-enclosed conditions.
    • Add line breaks with AND/OR to clearly distinguish logical conditions.
  4. Align Operators

    • Enable Align Compare Operators (<, >, =, …) to create visually consistent conditional statements.
  5. Indent BEGIN/END Blocks

    • Use the Indent BEGIN … END option to ensure procedural blocks are aligned and easy to follow.

Tips for Optimal Usage

  • Use Indent THEN and Indent ELSE for a clear hierarchical structure in conditional statements.
  • Enable Align Compare Operators to ensure conditions are easy to read, especially in complex queries.
  • Add line breaks with AND/OR to separate logical operators and improve readability.
  • Indent BEGIN … END blocks to reflect their nested nature and maintain clarity in procedural SQL.