Skip to content

SQL block indentation

Tako Lee edited this page Mar 12, 2014 · 15 revisions
  • If SQL block of create function/procedure is a single statement

    Option: fmt127_indent_procedure_body = n, type: TFmtInt.

    CREATE PROCEDURE humanresources.Uspgetallemployees  
    AS  
       SELECT lastname, 
              firstname, 
              jobtitle, 
              department  
       FROM   humanresources.vemployeedepartment;  
  • SQL block with BEGIN/END keyword

    Option: fmt128_indent_procedure_body_begin_keyword_in_newline = true, type: TFmtBoolean.

    Option: fmt129_indent_procedure_body_begin_keyword = 0, type: TFmtInt.

    Option: fmt130_indent_procedure_body_end_keyword_in_newline = true, type: TFmtBoolean.

    Option: fmt131_indent_procedure_body_end_keyword = 0, type: TFmtInt.

    Option: fmt132_indent_procedure_body_begin_end_block = 2, type: TFmtInt.

    CREATE PROCEDURE humanresources.Uspgetallemployees  
    AS  
    BEGIN  
      SELECT lastname, 
             firstname, 
             jobtitle, 
             department  
      FROM   humanresources.vemployeedepartment;  
    END  
    • Specify indentation size of BEGIN/END keyword, indentation size of SQLs inside block related to BEGIN/END keyword.

    Option: fmt128_indent_procedure_body_begin_keyword_in_newline = true, type: TFmtBoolean.

    Option: fmt129_indent_procedure_body_begin_keyword = 2, type: TFmtInt.

    Option: fmt130_indent_procedure_body_end_keyword_in_newline = true, type: TFmtBoolean.

    Option: fmt131_indent_procedure_body_end_keyword = 2, type: TFmtInt.

    Option: fmt132_indent_procedure_body_begin_end_block = 2, type: TFmtInt.

    CREATE PROCEDURE humanresources.Uspgetallemployees  
    AS  
      BEGIN  
        SELECT lastname, 
               firstname, 
               jobtitle, 
               department  
        FROM   humanresources.vemployeedepartment;  
      END  
    • BEGIN keyword can be specified not on a new line (Apply to BEGIN keyword in if/while/loop statement only )

    Option: fmt128_indent_procedure_body_begin_keyword_in_newline = false, type: TFmtBoolean.

    Option: fmt130_indent_procedure_body_end_keyword_in_newline = true, type: TFmtBoolean.

    Option: fmt131_indent_procedure_body_end_keyword = 2, type: TFmtInt.

    Option: fmt132_indent_procedure_body_begin_end_block = 2, type: TFmtInt.

    Option: fmt139_indent_else_body = 2, type: TFmtInt.

    IF @cost <= @compareprice BEGIN  
      PRINT 'These products can be purchased for less than '  
      END  
    ELSE  
      PRINT 'The prices for all products in this category exceed '
Clone this wiki locally