Moving commas from "end" to "start" is always buggy when comments exist
Moving commas from "end" to "start" or vice-versa is buggy when comments exist after each column or parameter. This is an issue regardless of the type of statement (SELECT, INSERT, UPDATE, CREATE TABLE/VIEW/FUNCTION/STORED PROCEDURE, etc).
Here is my original SP with commas at "end" followed by comments (hyphens are used for indentation due to HTML formating issues):
CREATE PROCEDURE dbo.MyProcedure
---- @Param1 int, --Param1 comments
---- @Param2 int, --Param2 comments
---- @Param3 int --Param3 comments
AS
BEGIN
---- SELECT Col1 , --Col1 comments
---- ---- Col2 , --Col2 comments
---- ---- Col3 --Col3 comments
---- FROM MyTable
---- RETURN
END
GO
After CTRL+K+Y, the commas and comments are incorrectly placed on their own separate line:
CREATE PROCEDURE dbo.MyProcedure
---- @Param1 int
---- , --Param1 comments
---- @Param2 int
---- , --Param2 comments
---- @Param3 int --Param3 comments
AS
---- BEGIN
---- ---- SELECT Col1
---- ---- ---- , --Col1 comments
---- ---- ---- Col2
---- ---- ---- , --Col2 comments
---- ---- ---- Col3 --Col3 comments
---- ---- FROM MyTable
---- ---- RETURN
---- END
GO
Alternatively when moving commas from "start" to "end" the commas are placed on their own line, but at least comments follow the statement. Going from either direction, this formatting is both ugly and unproductive. Moving comments to a new line is confusing! Either way this buggy issue robs us of valuable vertical screen space.
We regularly receive code that needs to be re-formatted to our own preferences. Please modify SQL Prompt to always leave both commas AND comments on the same line but still move commas to our preferred location ("start" or "end").
Thank you.
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!
-
Andrew Higgins commented
Please also see this similar issue:
---- exclude comments from "start new line at Boolean operator"
-
Josh commented
Please also see this similar issue (vote for both if you agree):
---- Auto generated INSERT statement is buggy with commas at start