What are the challenges you face when working across database platforms? Take the survey
Options

Styles: Different Alignment Behavior for AS keywords

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):
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

Sign In or Register to comment.