Click or drag to resize

SA0212 : The SETUSER is deprecated. It is recommended to use EXECUTE AS instead

The topic describes the SA0212 analysis rule.

Message

The SETUSER is deprecated. It is recommended to use EXECUTE AS instead

Description

The rule checks T-SQL code for usages of SETUSER statement.

The SETUSER is included for backward compatibility only and may not be supported in a future versions of Microsoft SQL Server.

It is recommended to use EXECUTE AS instead.

Scope

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

Parameters

Rule has no parameters.

Remarks

The rule does not need Analysis Context or SQL Connection.

Categories

New Rules, Deprecated Features

Additional Information
Example Test Script
SQL
1SETUSER 'mary';  
2
3GRANT SELECT ON computer_types TO joe;  
4
5SETUSER;

Analysis Results

 MessageLineColumn
1SA0212 : The SETUSER is deprecated. It is recommended to use EXECUTE AS instead.10
2SA0212 : The SETUSER is deprecated. It is recommended to use EXECUTE AS instead.50
See Also

Other Resources