Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

It is fairly common knowledge that you should have

SET NOCOUNT ON   

by default when creating new stored procedures.

Microsoft has changed the default template to include this in 2012. I thought this should be the same for triggers, yet it is not included in the template.

Is this intentional or just an oversight?

share|improve this question
1  
If you ever edit values via the SSMS table editor this is required for triggers otherwise the extra row count message from the trigger confuses it –  Martin Smith Jul 19 '12 at 13:05
    
it's an oversight most likely. Also see stackoverflow.com/questions/1483732/set-nocount-on-usage please –  gbn Jul 19 '12 at 14:21

1 Answer 1

up vote 10 down vote accepted

Personally, I would recommend it - I can't think of a reason not to, unless you have a trigger where you specifically want to call out the fact that it's doing additional work behind the scenes.

I wrote a short article about things to watch for when writing triggers, and this is one of them:
http://dave.brittens.org/2012/03/29/writing-well-behaved-triggers/

tl;dr version:

  1. Cut the chatter. Use NOCOUNT.
  2. Make sure your trigger can handle multiple rows.
  3. Prevent unbounded trigger cascading and recursion.
  4. Avoid horrible performance of the INSERTED and DELETED virtual tables.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.