Trigger to fire when inserting rows in tbale

  • Hi ALl

    I am trying to fire a trigger when I am trying to excute the statement : SELECT * INTO Table_BACKUP from TABLE

    Defined a AFTER INSERT trigger on TABLE_BACKUP but its not doing anything?

    CAn you please help?

    Meghna

  • SELECT INTO creates a new table and requires that the table specified in the INTO does not exist, hence I struggle to see how you've defined a trigger on a table that won't exist until after the select into runs

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • GilaMonster is correct about the Select Into. But if you are trying to create an insert trigger after an insert into a table in most other ways there are numerous examples of how to build that trigger.

    SOmething like the normal

    CREATE TRIGGER myAfterInsertTrigger

    ON mytable

    AFTER INSERT

    AS

    ...

    GO

    Not all gray hairs are Dinosaurs!

Viewing 3 posts - 1 through 2 (of 2 total)

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