DML Triggers

  • I find a certain shortcoming in the logic of the answer -- its the logic of an attorney not of a mathematician. 😉 I seldom reply to the QOD thing, but BOL was clear;

    Because a CLR trigger can be a DDL trigger does NOT mean that it is not a DML trigger -- sheesh!

  • I haven't used CLR or researched it much, but as far as DML goes, surely CLR triggers would fall under the same logic as a traditional DML trigger:

    1. do [action] AFTER insert/update/delete


    2. do [action] INSTEAD OF insert/update/delete

    The CLR bit as far as I can see is just an alternative to T-SQL. Where it appears in BOL is not necessarily an indication of correctness as far as this QoD goes, seeing as CLR triggers can be either DML or DDL. Perhaps BOL should state 'DML|DDL triggers can be written in either T-SQL or CLR'.

    /Edit: must stop using gt/lt brackets, they get stripped out.

    Scott Duncan

    MARCUS. Why dost thou laugh? It fits not with this hour.
    TITUS. Why, I have not another tear to shed;
    --Titus Andronicus, William Shakespeare

  • I'm not a huge fan of the BOL article referenced, I answered the question as the author of the question intended, so I'm a bit biased, but I think that BOL calling CLR a type of trigger, just like AFTER or INSTEAD OF, is logically inconsistent. CLR is just a means for creating a DML or DDL trigger, which I think is supported by other descriptions elsewhere in BOL, including the oft-cited article in this thread. And what does 'type' actually mean? In this case it seems to mean WHEN the trigger should do its action....that is until you bring CLR into it. CLR does not answer WHEN but rather how the trigger is created.

    Anyway, I still think that BOL article is bad, adds nothing to the understanding of triggers, and the information in it could probably be rolled into both the descriptions for DML and DDL triggers as well as articles on creating triggers using CLR.

  • Prashant Pandey (12/12/2007)

    Yelena Varshal (12/12/2007)

    I was surprised at the logic:

    "....This link also contain CLR Triggers but they can also be a DDL trigger that is why they cannot be count under the pur DML triggers category..."

    If CLR Triggers can be something else than DML Triggers, it does not mean it is not the valid type for DML Triggers. It just means it is the valid type for other types of triggers too. The question was "How many types for DML Triggers" and it is 3. This is similar of how we have a "priority one" for so many different things and the fact that we have issues of "priority one" , tasks of "priority one", goals of "priority one" etc does not mean that "priority one" is not a valid type for issues for example because it is a valid type for many other categories.


    ur right... i think i am wrong, But if u see that question is "How many Types of DMLTriggers" so i think if u ask about all versions of sql then commonly there are two. AFTER and INSTEAD and FOR is not a seprate it comes under AFTER,

    CLR Triggers are implemented in SQL 2005. they are not in 7.0 and 2000 and i think AFTER and INSTEAD OF both are there in all versions.

    but if u consider the latest which always prefered .. then question needs some modification and it should be like below.

    How many Types of DML Triggers in the SQL2005??

    and answer will be AFTER, INSTEAD OF and CLR Triggers.

    What you think???

    I think INSTEAD OF trigger started with SQL 2000. That would make none of your choices valid.

    I don't think your logic here is correct. If your original question intended to encompass versions 7.0, 2000, and 2005 without explicitly listing them, what about earlier versions like 6.x or 4.x?

  • Ok, so CLR isn't a PURE DML trigger. But it CAN be a DML trigger.

    I've checked and rechecked, and the word 'pure' doesn't occur in the question.

    It's a very misleading/ambiguous Q. So as the answer I wanted wasn't there (the 3 as in BOL), I decided the answer was 1 - a DML trigger is a DML trigger!

  • The question is: "how many types of DML triggers in present?" So the answer should be : 3 types of DML triggers: CLR Triggers, AFTER Triggers,INSTEAD OF Triggers.



    '[font="Tahoma"]The bend in the road is not the end of the road Unless u refuse to take the turn[/font]"

  • I'm afraid the answer is wrong .... saying that the CLR trigger isn't a DML trigger because they can also be DDL triggers is just daft

    Don't know how poster will cope with quantam computing ... where qubits can be on, off or both 🙂 does that mean a qubit isn't a bit? or it can never be on or off because it can be both?

    Seems question is an attempt to 'prove' how clever poster is, and succeeds in demonstrating opposite 😀

  • Hi all,

    I'll have to disagree with the many objections and agree with the original question (now that is uncommon for me!). Though the explanation is confusing, misleading, and maybe even wrong, the answer is, in fact, correct.

    The explanation that CLR doesn't count as a seperate category because they can also be used as DDL triggers is of course utter ****. No arguing there. However, that doesn't make it a seperate category. It's just a different language to code a trigger in. So we have two categories: AFTER triggers (which may also be defined by using the keyword FOR instead of AFTER), which can be coded in either T-SQL or in .Net, and INSTEAD OF triggers, which also can be coded in either T-SQL or in .Net.

    If you want to consider CLR triggers a seperate category, fine - but then the total immediately bumps to four, because you then still have to distinguish CLR INSTEAD OF triggers from CLR AFTER triggers. There was no answer option including these two types of triggers, so it was clear that the "type" did not refer to the language.

    Everyone arguing that "CLR triggers" is in itself a single type of trigger is just wrong. So there, I've said it - let the flaming commence! 😉

    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog:
    SQL Server Execution Plan Reference:

  • I'll post my two cents worth.

    The question asks "How many types of DML triggers in SQL are present? (DML - Data Modification Language)" - it doesn't ask "How many types of pure DML triggers in SQL are present? (DML - Data Modification Language)".

    Since CLR is present in the DML language the correct answer based on the way the question is written is three.

    The answer given makes a qualification that is not in the question - That is the worst kind of trick question I can imagine.

  • I don't know, but I got the answer (per QoD) correct because it makes sense to me. There are two types of DML triggers: AFTER and INSTEAD OF. These can be written in TSQL or a CLR language. Just because BOL lists CLR triggers separately doesn't mean it is correct. Please, Microsoft doesn't always know best.


  • Andrew Fitzgerald (12/13/2007)Since CLR is present in the DML language the correct answer based on the way the question is written is three.

    Hi Andrew -- and everyone who has posted a similar thing.

    Please explain to me why you would divide DML triggers written in T-SQL into two categories (INSTEAD OF and AFTER), while at the same time lumping all DML triggers written in CLR into a single category? If a T-SQL INSTEAD OF trigger is different from a T-SQL AFTER trigger, then how can a CLR INSTEAD OF trigger not be different from a CLR AFTER trigger?

    There is no definition given for "type" in the question, so we have some leeway to create our own definitions. I can live with the answer "Two: CLR and T-SQL" (defining language as type). I can also live with the answer "Two: INSTEAD OF and AFTER" (as the question's author intended). And I'll also accept "Four: T-SQL INSTEAD OF, T-SQL AFTER, CLR INSTEAD OF, and CLR AFTER" as a legitimate answer. But three? No way!

    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog:
    SQL Server Execution Plan Reference:

  • MS On-line help for SQL lists three Types of DML triggers: After, Instead of and CLR.


    The only one in dispute is CLR which according to the authors of the question also exists in other Features and thus is not "pure". It may be semantics but the three that MS Lists trumps the answer given in my book.

  • Andrew Fitzgerald (12/13/2007)

    MS On-line help for SQL lists three Types of DML triggers: After, Instead of and CLR.

    Tempted as I now am to submit a documentation bug report, I can't deny that this is indeed exactly what Books Online says. I disagree with it (but that's not new, I disagree with lots of stuff in BOL), but it is official so I guess that those who answered "three (after, instead, clr)" should be awarded a point.

    And maybe the question needs to be retracted...

    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog:
    SQL Server Execution Plan Reference:

  • .... 4 surely - this included AFTER and INSTEAD OF and CLR, so we had to select this even though it also included FOR (even though this isn't really a type on its own) ...retract the question and revoke all points 🙂

  • The answer should be 3, After, Instead Of and CLR

Viewing 15 posts - 16 through 30 (of 34 total)

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