DF012: The SETUSER statement is deprecated.

The topic describes the DF012 T-SQL code analysis rule.

Category

Deprecated

Message

The SETUSER statement is deprecated.

Description

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

Additional information

The EXECUTE AS clause provides more granular control over execution permissions and is the preferred method for specifying the security context for stored procedures, functions, or triggers. Migrating from SETUSER to EXECUTE AS ensures compatibility with future versions of SQL Server and aligns with best practices for managing security within database systems.

Noncompliant code example

SETUSER 'Mary'
SELECT * FROM dbo.Customers

Compliant solution

EXECUTE AS user = 'Mary'
SELECT * FROM dbo.Customers

Want to Find out More?

Overview

Overview

Take a quick tour to learn all about the key benefits delivered by dbForge Studio for SQL Server.
All Features

All features

Get acquainted with the rich features and capabilities of the Studio in less than 5 minutes.
Request a demo

Request a demo

If you consider employing the Studio for your business, request a demo to see it in action.
Ready to start using dbForge Studio for SQL Server?