Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Do I need to turn NOCOUNT back on?

Author  Topic 

Eagle_f90
Constraint Violating Yak Guru

424 Posts

Posted - 2012-10-24 : 19:59:29
In all of my procs that only do updates/inserts I have SET NOCOUNT ON and have not had a problem in the past 3 months but today I was at my new job and noticed that the procs there that have SET NOCOUNT ON at the start also have SET NOCOUNT OFF at the very end of the proc. Is there any reason to turn NOCOUNT back on as the very last statment of a proc that only does inserts/updates?

--
If I get used to envying others...
Those things about my self I pride will slowly fade away.
-Stellvia

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-10-25 : 03:38:50
I think it is "clean" to do that but not important.


Too old to Rock'n'Roll too young to die.
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-10-25 : 04:48:20
It will be reset at the end of the proc so no need.
A bit like temp tables - no need to delete at the end but a create and drop would bracket the code.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

mmkrishna1919
Yak Posting Veteran

95 Posts

Posted - 2012-10-25 : 06:39:08
There is no need to SET NOCOUNT OFF at the end of the stored procedure. When you exit from the scope of the stored procedure.it will reset based on the configuration settings.

It will turn back ON if the connection is configured to have it turned ON by default.



M.MURALI kRISHNA
Go to Top of Page
   

- Advertisement -