Skip to content

SQL Server declare statement

Tako Lee edited this page Feb 17, 2014 · 3 revisions
  • Variables fit into same line

    • First variable in the same line as DECLARE keyword

      DECLARE @s VARCHAR(1000),@s2 VARCHAR(10)  
    • First variable in new line, indented by 0 or n

      DECLARE 
        @s VARCHAR(1000),@s2 VARCHAR(10)  
  • Stacked variables

    • First variable in the same line as DECLARE keyword

      • Comma at the end of line

        DECLARE @s VARCHAR(1000),
                @s2 VARCHAR(10)  
      • Comma at the begin of line

        DECLARE @s VARCHAR(1000)
                ,@s2 VARCHAR(10)  
      • Comma at the begin of line, align variables.

        DECLARE @s VARCHAR(1000)
               ,@s2 VARCHAR(10)  
      • Comma at the begin of line, align variables, space between comma and variable is 1 or n.

        DECLARE @s VARCHAR(1000)
              , @s2 VARCHAR(10)  
    • First variable in new line, indented by 0 or n

      • Comma at the end of line

        DECLARE 
          @s VARCHAR(1000),
          @s2 VARCHAR(10)  
      • Comma at the begin of line

        DECLARE 
          @s VARCHAR(1000)
          ,@s2 VARCHAR(10)  
      • Comma at the begin of line, align variables.

        DECLARE 
           @s VARCHAR(1000)
          ,@s2 VARCHAR(10)  
      • Comma at the begin of line, align variables, space between comma and variable is 1 or n.

        DECLARE 
           @s VARCHAR(1000)
         , @s2 VARCHAR(10)  
Clone this wiki locally