Code Analysis

DEP021

String literals as column aliases are deprecated

If aliases are standard identifiers, they do not need delimiters. If they are not, then they should be delimited by double-quotes, not single-quotes. SQL Server and Sybase allow square brackets for the same purpose, but this is not ANSI Standard SQL. String aliases are not part of the SQL standard, and have been deprecated by Microsoft when used with the assignment syntax. So, for example, SQL Prompt will raise a violation of DEP021 for statements such as the following:

SELECT Schema_Name(schema_id)+'.'+[name] AS 'My Tables' FROM sys.tables 

For further details and examples, please see this Product Learning article: SQL Prompt code analysis: avoid non-standard column aliases (ST002 and DEP021).

Available in

SQL Prompt

SQL Code Guard



Didn't find what you were looking for?