SA0160 : Deprecated use of @, @@, or names that begin with @@ as Transact-SQL identifiers |
![]() |
Identifiers that start with @ or @@ in T-SQL can lead to confusion and errors in code interpretation.

In T-SQL code, @ is commonly used for declaring and referencing local variables, while @@ is used for system functions (or global variables like @@SERVERNAME). Misusing these conventions by naming tables, columns, or user-defined variables in a similar manner can cause conflicts or unexpected behavior, as these symbols have predefined meanings.
For example:
1-- Example of problematic use of identifiers 2SELECT @@someGlobalVar FROM MyTable; 3CREATE TABLE @myTable (ID INT);
In the first example, using @@ suggests a system function, which can be misleading if not correctly defined. In the second example, using @myTable can cause confusion, as it mimics local variable syntax, leading to potential misinterpretation within scripts or stored procedures.
-
Creates ambiguity in distinguishing between system functions and user-defined identifiers.
-
Increases risk of syntax errors or logical errors in queries and stored procedures.
-
Can lead to maintenance challenges and lower code readability.

Avoid using identifiers that start with @ or @@ to prevent confusion and errors in T-SQL code interpretation.
Follow these steps to address the issue:
-
Review the reported identifier and understand its current usage within your database scripts or code.
-
Rename the identifier to a more descriptive and unique name that does not begin with @ or @@. This will ensure it is not mistaken for a local or system-defined variable.
-
Update all references to the renamed identifier within your database objects, such as tables, stored procedures, and functions, to ensure consistency and prevent errors.
For example:
1-- Example of corrected query 2CREATE TABLE MyTable (ID INT); 3SELECT someGlobalVar FROM MyTable;

The rule has a Batch scope and is applied only on the SQL script.

Rule has no parameters.

The rule does not need Analysis Context or SQL Connection.


Design Rules, Naming Rules, Deprecated Features, Bugs


SQL
1declare @ as int, @@ as int, @@a bit ,@@b int |

Message | Line | Column | |
---|---|---|---|
1 | SA0160 : Deprecated use of @, @@, or names that begin with @@ as Transact-SQL identifiers. | 1 | 8 |
2 | SA0160 : Deprecated use of @, @@, or names that begin with @@ as Transact-SQL identifiers. | 1 | 18 |
