DF210: The SET NOCOUNT OFF statement is used.

Last modified: December 25, 2024

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

Category

PERFORMANCE

Message

The SET NOCOUNT OFF statement is used.

Description

Turning off the NOCOUNT setting is not recommended, as it results in sending unnecessary messages to the client.

Additional information

It is important to note that turning off the NOCOUNT setting is generally not recommended. This setting suppresses the “xx rows affected” message that SQL Server sends to the client after executing statements. By leaving NOCOUNT on, unnecessary messages are avoided, reducing network traffic and potentially improving performance, especially in scenarios involving multiple statements or large result sets.

Noncompliant code example

CREATE PROCEDURE dbo.DemoProc
AS
BEGIN
    SET NOCOUNT OFF;
    SELECT * FROM dbo.DemoTable
END
GO

Compliant solution

CREATE PROCEDURE dbo.DemoProc
AS
BEGIN
     
    SELECT * FROM dbo.DemoTable
END
GO