@@rowcount Returns 0

  • Heh... looks like you've been bitten before, eh Juan? 

    So far as the ANSI_NULLs thing goes, the default setting, when you create an SQL Server instance, is ON.  Unless someone changed it, it shouldn't need to be explicitly set especially in a trigger.

    So far as the ANSI_Warnings, it's mostly for GUI code that you would want this to be OFF just as you would want SET NOCOUNT to be ON to keep from giving "false" result sets to the GUI.  However, updates, inserts, and deletes to tables with indexes on computed columns or indexed views will fail (according to Books Online) if ANSI_Warnings is set to OFF.  Same holds true for ARITHABORT and a couple of other settings.

    Bottom line is that the server defaults will do everything you need to if no one messed around with the default settings and you shouldn't have to explicity set them except in the rare instance of some PFM.  If you want to feel better about the triggers, though, you can still set them... just don't do it right after the "AS"... check the rowcount first.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • What a waste to fire a trigger when nothing has really happened. What could you possibly want to do? You have pretty much no information to do anything with.

  • Maybe to have something else happen just because there was no records affected?

  • Yep... like maybe to send an email to notify of a zero rows situation or maybe just log that nothing happened... hadn't thought about that before.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 4 posts - 16 through 18 (of 18 total)

You must be logged in to reply to this topic. Login to reply