• shohelr2003 (3/21/2013)


    @Eugene Elutin,

    Can you please tell me the basic difference between FOR INSERT and INSTEAD OF INSERT Trigger.

    I know there are lots of resources on it. But please tell me in short.

    In short?

    Number of words! FOR INSERT has two, INSTEAD OF INSERT has three! 😉

    Ok, only joking...

    The main difference is: FOR INSERT trigger is the one which will shot before inserted data is committed into table. INSTEAD OF trigger, will stop any insert happening and replace it with the logic you have in this trigger. Basically, your INSTEAD OF trigger can actually do delete or update or anything else with its own or any other table.

    When you may want to use it?

    One of the common examples would be when you want make non-updatedable view to be updateable. Using INSTEAD OF trigger will help you here. Let's say you view if join between three tables. You cannot insert directly into this view. However, you can add INSTEAD OF trigger which will use specific logic and insert records into three separate tables.

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]