SA0218 : The ‘::’ function calling syntax is deprecated |
![]() |
The usage of the deprecated built-in function calling syntax ::function_name() in T-SQL code can cause compatibility issues in future SQL Server versions.

This rule identifies and highlights the use of deprecated syntax for calling built-in functions in T-SQL code. The specific syntax involves using ::function_name(), which is an outdated practice in SQL Server.
The recommended approach is to use the sys.function_name() syntax. Continuing to use the deprecated method can lead to compatibility issues with newer SQL Server versions and reduce code maintainability.
For example:
1-- Example of deprecated function call 2SELECT ::fn_virtualfilestats(1, 1);
Using ::fn_virtualfilestats() can cause problems because this syntax is no longer supported in recent SQL Server versions. Instead, it is better to use:
1-- Recommended function call 2SELECT sys.fn_virtualfilestats(1, 1);
-
Using deprecated syntax can lead to errors during code execution or upgrades, as it might not be supported in future SQL Server releases.
-
Employing the updated syntax improves code readability and maintenance, as it aligns with current SQL Server standards and practices.

Update deprecated system function calls to ensure compatibility and maintainability.
Follow these steps to address the issue:
-
Identify all occurrences of system functions using the deprecated ::function_name() syntax in your T-SQL scripts.
-
Replace the deprecated syntax with the current sys.function_name() format to adhere to modern SQL Server standards.
-
Test the updated scripts to verify that they work correctly with the new syntax and perform as expected.
For example:
1-- Example of deprecated function call 2SELECT ::fn_virtualfilestats(1, 1); 3 4-- Recommended function call 5SELECT sys.fn_virtualfilestats(1, 1);

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.


Deprecated Features, Bugs


SQL
1-- Deprecated syntax usage. 2SELECT * FROM ::fn_virtualfilestats(2,1) 3 4-- Correct function call syntax. 5SELECT * FROM sys.fn_virtualfilestats(2,1) |

Message | Line | Column | |
---|---|---|---|
1 | SA0218 : The ‘::’ function calling syntax is deprecated. | 2 | 16 |
