How can we help you today? How can we help you today?

Table Variables formatted with schema settings

When I enable the Schema statements settings:
New Line on Open parenthesis of a definition
New Line on First definition
New Line on Closing parenthesis of a definition

and then format a stored procedure with a table variable, the table variable is formatted using the above settings.
CREATE PROCEDURE dbo.Test1
(
  @param1 INT
, @param2 INT
)
AS 
BEGIN
    DECLARE @temp1 TABLE ( col1 INT, col2 INT, col3 INT, col4 INT )
	
    SELECT  *
    FROM    @temp1 AS t1
    WHERE   t1.col1 = @param1
            AND t1.col2 = @parm2
	
END
GO

After formatting
CREATE PROCEDURE dbo.Test1
(
  @param1 INT
, @param2 INT 
)
AS 
BEGIN
    DECLARE @temp1 TABLE
(
  col1 INT
, col2 INT
, col3 INT
, col4 INT
)
	
    SELECT  *
    FROM    @temp1 AS t1
    WHERE   t1.col1 = @param1
            AND t1.col2 = @parm2
	
END
GO

I don't believe that the table definition should be aligned to the left hand column like the procedure parameters. Instead I would have expected this:
CREATE PROCEDURE dbo.Test1
(
  @param1 INT
, @param2 INT 
)
AS 
BEGIN
    DECLARE @temp1 TABLE
    (
      col1 INT
    , col2 INT
    , col3 INT
    , col4 INT
    )
	
    SELECT  *
    FROM    @temp1 AS t1
    WHERE   t1.col1 = @param1
            AND t1.col2 = @parm2
	
END
GO

I've tried the Indent definition option but I prefer not to indent parenthesis.

Tested using SQL Prompt 5.0.1.7 and 5.1 beta.
DaveB
0

Comments

2 comments

  • Anu D
    Many thanks for your post Dave.

    Can you try reformatting after selecting the option 'Indent Definition' child option of 'First Definition'?

    Does that make any difference?
    Anu D
    0
  • DaveB
    Yes, I am aware of those settings and yes they make a difference, but I don't care for how it then indents the procedure parameters and parenthesis.

    I think that table variables and function / procedure definitions need to be handled via separate formatting settings.

    Thanks for the response.

    -Dave
    DaveB
    0

Add comment

Please sign in to leave a comment.