DF039: The SET statement for QUOTED_IDENTIFIERS or ANSI_NULLS inside the stored procedure, trigger, or function body is used.

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

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?