DF004: The SET statement is used within a stored procedure.
Last modified: May 28, 2025
The topic describes the DF004 T-SQL code analysis rule.
Category
PERFORMANCE
Message
The SET statement is used within a stored procedure.
Description
Changing the SET options for ANSI_DEFAULTS, ANSI_NULL_DFLT_OFF, ANSI_NULL_DFLT_ON, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, CONCAT_NULL_YIELDS_NULL, DATEFIRST, DATEFORMAT, LANGUAGE, NO_BROWSETABLE, or NUMERIC_ROUNDABORT leads to the recompilation of the affected stored procedure.
Additional information
During execution or runtime, all SET statements operate, with the exception of those running at parse time, including SET FIPS_FLAGGER, SET OFFSETS, SET PARSEONLY, and SET QUOTED_IDENTIFIER.
Noncompliant code example
Noncompliant code example
CREATE PROCEDURE dbo.SelectUserData
AS BEGIN
SET NOCOUNT ON;
SET ANSI_WARNINGS OFF;
SELECT * FROM dbo.UserData;
END
GO
Compliant solution
CREATE PROCEDURE dbo.SelectUserData
AS BEGIN
SET NOCOUNT ON;
/* remove usage of SET ANSI_WARNINGS*/
SELECT * FROM dbo.UserData;
END
GO
Want to find out more?
Overview
Take a quick tour to learn all about the key benefits delivered by dbForge Studio for SQL Server.
All features
Get acquainted with the rich features and capabilities of the tool in less than 5 minutes.
Request a demo
If you consider employing this tool for your business, request a demo to see it in action.