Format CTEs to keep the semicolon on the same line as the "With"
When you format:
SELECT x from y
;WITH NumberSequence ( MonthNumber )
AS ( SELECT 1 AS MonthNumber
UNION ALL
SELECT MonthNumber + 1
FROM NumberSequence
WHERE MonthNumber < 12
)
You move the semicolon to the end of the previous command instead of leaving it with the CTE and remove the blank line:
SELECT x from y;
WITH NumberSequence ( MonthNumber )
AS ( SELECT 1 AS MonthNumber
UNION ALL
SELECT MonthNumber + 1
FROM NumberSequence
WHERE MonthNumber < 12
)
Should leave the blank line and semicolon where they are.
Thanks,
Tom
Thank you for your suggestion.
We’ve reviewed this as part of our UserVoice triage.
We’ve decided not to implement this feature as there is not enough evidence/demand at this point in time to justify its implementation.
Kind Regards,
The Prompt Team
-
JBrune commented
I agree with anonymous. Semicolons are not required for queries in SQL server, except for CTEs.
-
Anonymous commented
Pretty much, 99% of SQL development that I have seen never use any semi-colons. The only time they are used are with CTEs.
So, putting the ; in front of the WITH actually make things cleaner IMO.
-
Stefan Hoffmann commented
I agree with Chris. It must be optional and opt-in.
-
Chris Luttrell commented
I have to agree if you implement this to make it optional and not this way by default. It goes against good practice and the standard to put the semicolon in front of the WITH.
-
WesH commented
Since this is now under review, I'll suggest an option to always keep the semi-colon on its own line. I don't like it on the same line as the last statement because I may want to append to that statement and need to move/remove the semi-colon before I can start typing. If it was on its own line below the statement, I can just start typing in front of it.
I still don't want it moved to the start of the next statement, but hopefully putting it onto its own line can be an effective compromise to both sides of the argument.
-
Brad Simpson commented
If implemented: optional, please.
-
WesH commented
If this is implemented, please make it optional. I require my developers to end their statement with a semi-colon, not start the next statement with one.