DF039: The SET statement for QUOTED_IDENTIFIERS or ANSI_NULLS inside the stored procedure, trigger, or function body is used.
Last modified: December 25, 2024
The topic describes the DF039 T-SQL code analysis rule.
Category
EXECUTION RULES
Message
The SET statement for QUOTED_IDENTIFIERS or ANSI_NULLS inside the stored procedure, trigger, or function body is used.
Description
It is not recommended to set the QUOTED_IDENTIFIERS or ANSI_NULLS options inside a stored procedure, trigger, or function as this will have no effect.
Additional information
The settings of QUOTED_IDENTIFIERS and ANSI_NULLS apply to the entire session. Setting them within a stored procedure, trigger, or function would affect only that specific object’s execution context but not the entire session. This could lead to unexpected behavior and potential conflicts with other parts of the code executing in the same session.
Noncompliant code example
CREATE PROCEDURE dbo.DemoProc
AS
BEGIN
SET NOCOUNT ON;
SET QUOTED_IDENTIFIER ON;
SET ANSI_NULLS OFF;
SELECT
CityId
,CityName
FROM dbo.City;
END;
GO
Compliant solution
SET QUOTED_IDENTIFIER ON;
SET ANSI_NULLS OFF;
GO
CREATE PROCEDURE dbo.DemoProc
AS
BEGIN
SET NOCOUNT ON;
SELECT
CityId
,CityName
FROM dbo.City;
END;
GO
Was this page helpful?