Styles: Different Alignment Behavior for AS keywords
athornbury
Posts: 6 Bronze 2
in SQL Prompt
My personal preference is to always have the keyword AS consistently aligned when used to specify an alias or when used for datatype assignment. The style options do not currently seem to be able to do this.
Global --> Lists --> Aliases and comments: the "Align aliases" option aligns all of the occurrences of the keyword AS to first tab character after the longest list member. This is the desired behavior I would like to see. For example the following code block demonstrates the desired behavior (hopefully formatting is preserved):
Staements --> Variables --> Declare: The "Align data types and values" options aligns the data types and subsequent values, but the keyword AS statement is left behind. This is not the desired behavior. For example the following code block demonstrates this (hopefully formatting is preserved):
Is there any way to achieve this currently? I could drop the use of the keyword AS when it is used to declare variable data type, but I believe it is still the approved SQL standard syntax.
Thanks!!
Global --> Lists --> Aliases and comments: the "Align aliases" option aligns all of the occurrences of the keyword AS to first tab character after the longest list member. This is the desired behavior I would like to see. For example the following code block demonstrates the desired behavior (hopefully formatting is preserved):
SELECT TerritoryID , Name , [Group] -- nvarchar(50) , SalesYTD AS YearToDate -- money , SalesLastYear AS LastYear -- money FROM Sales.SalesTerritory;
Staements --> Variables --> Declare: The "Align data types and values" options aligns the data types and subsequent values, but the keyword AS statement is left behind. This is not the desired behavior. For example the following code block demonstrates this (hopefully formatting is preserved):
DECLARE @ErrorMessage AS NVARCHAR(MAX) , @ErrorLine AS NVARCHAR(5) = CONVERT(NVARCHAR(5), ERROR_LINE()) , @ErrorNumber AS INT = ERROR_NUMBER() , @ErrorMessage2 NVARCHAR(MAX) , @ErrorLine2 NVARCHAR(5) = CONVERT(NVARCHAR(5), ERROR_LINE()) , @ErrorNumber2 INT = ERROR_NUMBER();
Is there any way to achieve this currently? I could drop the use of the keyword AS when it is used to declare variable data type, but I believe it is still the approved SQL standard syntax.
Thanks!!
Tagged:
Answers
Thanks for the post. There's no way to do this currently unfortunately, but I agree we should be able to! We'll look into it and hopefully have a fix out soon
Thanks for your patience
Regards,
James
Redgate Software