This statement is used to stop the message that shows the count of the number of rows affected by the SQL statement written in the stored procedure or directly SQL Statement
When it is ON - the number of affected rows will not be returned
When it is OFF - the number of affected rows will be returned
Example
USE AdventureWorks2012;
GO
SET NOCOUNT OFF;
GO
-- Display the count message. The number of affected rows will be returned
SELECT TOP(5)LastName
FROM Person.Person
WHERE LastName LIKE 'A%';
GO
-- Disable the Count massage Then Number of affected rows will not be returned.
SET NOCOUNT ON;
GO
SELECT TOP(5) LastName
FROM Person.Person
WHERE LastName LIKE 'A%';
GO
-- Reset SET NOCOUNT to OFF
SET NOCOUNT OFF;
GO
Thanks for All
Eng. Mustafa Elmasry
MSSQL DBA
Like this:
Like Loading...
Related
Published by Mustafa EL-Masry
I am Microsoft database consultant working as a Database administrator for more than +10 Years I have very good knowledge about Database Migration, Consolidation, Performance Tuning, Automation Using T-SQL, and PowerShell and so many other tasks I do it in multiple customers here in KSA and as of now, I am working in Bank Albilad managing the core banking system that is hosted in SQL Server Database 8 TB. Also, I am Microsoft certified 2008 and 2016 in SQL Server (2x MCTS, 2x MCTIP, MCSA, MCSE) and I am Microsoft Certified Trainer (MCT) also I am azure Certified (AZ-900, AZ-103) also I was awarded by Microsoft Azure Heroes 3 times as (Azure Content hero, Azure Community hero and Azure Mentor) For more information check my page
https://mostafaelmasry.com/about-me/
View all posts by Mustafa EL-Masry