Line up type declarations
I would like an option to align the type declarations, for example when declaring the columns in a table variable I currently get:
DECLARE @MyExample TABLE
(
MyCol1 INT ,
MyOtherCol VARCHAR(10)
)
Which I would quite like to see laid out as:
DECLARE @MyExample TABLE
(
MyCol1 INT ,
MyOtherCol VARCHAR(10)
)
The same is true for all other places where I'm declaring, so the parameters for a procedure for example
This feature is now included in the new SQL Prompt 8.0. For additional information see: http://documentation.red-gate.com/display/SP8/SQL+Prompt+8.0+release+notes
You can get the latest version of SQL Prompt from http://www.red-gate.com/products/sql-development/sql-prompt/
Thank you for your help!
-
Paul J commented
I'd really like to see this as well. so I'd have:
DECLARE
~~~~@VariableOne~~~~~~~~~~~~~~VARCHAR(50)~~~~~~~~= NULL
~~~~@VariableTwo~~~~~~~~~~~~~~INT~~~~~~~~~~~~~~~~~NULL
~~~~@VariableThree~~~~~~~~~~~~VARCHAR(50)~~~~~~~~NULL
~~~~@VariableLongername~~~~~~~VARCHAR(50)~~~~~~~~NULLSorry, I realize the above is not exactly aligned, but this is best I could do in this forum post.
The idea being that all the variables are aligned, their types aligned, and their default values aligned. It obviously would need to somehow determine the longest variable name, and default to 4 spaces (or similar) after that for the starting position of aligning the types.
Would like it to further format other things in this similar fashion: i.e. for SET statements:
SET @VariableOne~~~~~~~~= NULL
SET @VariableTwo~~~~~~~~~= NULLetc.
-
JRiedemann commented
I'd suggest a 4th column which would contain default constraints, identity definitions and collation information:
CREATE TABLE dbo.fred
~~(
~~~~field1~~~~INT~~~~~~~~~IDENTITY(1,~1)~~~~~~~~~~~~~~NOT~NULL,
~~~~x~~~~~~~~~VARCHAR(10)~COLLATE~DATABASE_DEFAULT~~~~NOT~NULL,
~~~~field123~~INT~~~~~~~~~CONSTRAINT~df_123~DEFAULT~6~NOT~NULL
~~); -
Wes Winkler commented
I agree. I would also like to see the NULL/NOT NULL words aligned in a third column. The CREATE TABLE statement would then visually lay out in three nice columns: the first is the column name (as wide as longest column name), the second is the datatype (as wide as the longest datatype), and the third is NULL/NOT NULL.
Again, this is hard to send across the web, which strips out the whitespace.
-
Simon commented
Annoyingly the white space was removed from my suggestion :(
I would like to see the example laid out as:
DECLARE @MyExample TABLE
(
MyCol1 ---------INT ,
MyOtherCol ---VARCHAR(10)
)
Where the - would be a space character (or tabs, depending on user preference)