none
INSERTED table and triggers RRS feed

  • Question

  • Hi. I was dealing with triggers when a doubt came in mind.

    While I can understand that the DELETED and UPDATED tables can contain more rows that have been affected by the DELETE or the UPDATE statment, the INSERTED table that I read in a "FOR INSERT" trigger has just 1 row or can have more rows?

    Thanks.

     

    Monday, March 19, 2007 10:15 AM

All replies

  • many rows. Number of rows depended on how many rows get deleted / updated / inserted
    Monday, March 19, 2007 11:43 AM
  • Image the query

    INSERT INTO SomeTable
    SELECT SomeCOlumn From ManyRowTable

    That will bring up more than one row. bew also aware that the trigger is fired upon DML statement not per row, this means that a query like

    INSERT INTO SomeTable
    SELECT SomeColumn From SomeTable2 Where 1 = 0

    also brings the trigger to fire.

    HTH, Jens K. Suessmeyer.

    ---
    http://www.sqlserver2005.de
    ---
    Monday, March 19, 2007 1:24 PM
    Moderator