Hi all,
How to use SET NOCOUNT ON and why to use in SQL Server .
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Amit MohantyRank #112 · 20K reputationPosted Jul 7, 2019, 11:26 PM EDT
https://www.c-sharpcorner.com/blogs/set-nocount-on-and-set-nocount-off-using-stored-procedure-in-sql-server
https://www.tutorialgateway.org/sql-set-nocount-on/
https://www.tech-recipes.com/rx/56506/sql-server-set-nocount-on-statement-with-examples/
Madan ShekarRank #428 · 5.9K reputationPosted Jul 7, 2019, 11:25 PM EDT
Rajanikant HawaldarRank #110 · 20.2K reputationPosted Jul 7, 2019, 11:42 PM EDT
Sivakumar KonetiRank #1,557 · 1K reputationPosted Jul 8, 2019, 8:48 PM EDT
Subbarao ARank #2,632 · 530 reputationPosted Jul 9, 2019, 11:22 PM EDT
Mageshwaran RRank #411 · 6.1K reputationPosted Nov 5, 2019, 3:58 AM EST
Vinitha TRank #8,005 · 230 reputationPosted Nov 8, 2021, 8:56 AM EST
SET NOCOUNT ON - This prevent to display number of row(s) affected and will display as Commands completed successfully in message tab
SET NOCOUNT OFF - This display number of row(s) affected.
geetha velusamy52 reputationPosted Nov 12, 2021, 8:03 AM EST
SET NO COUNT ON:
SET NO COUNT is ON the count is not returned.
Sample Query for SET NO COUNT ON:
SET NOCOUNT ON;
GO
SELECT [empid]
,[empname]
,[email]
,[address]
FROM [emp]
SET NO COUNT OFF:
SET NO COUNT is OFF it returns the count of rows affected.
Sample Query for SET NO COUNT OFF:
SET NOCOUNT OFF;
GO
SELECT [empid]
,[empname]
,[email]
,[address]
FROM [emp]