Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

Trigger to fire when inserting rows in tbale Expand / Collapse
Posted Thursday, May 16, 2013 3:25 AM


Group: General Forum Members
Last Login: Monday, January 26, 2015 6:16 AM
Points: 114, Visits: 429
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?

Post #1453384
Posted Thursday, May 16, 2013 3:35 AM



Group: General Forum Members
Last Login: Today @ 6:14 AM
Points: 43,437, Visits: 40,568
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
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

Post #1453388
Posted Friday, May 17, 2013 3:34 PM


Group: General Forum Members
Last Login: Thursday, August 6, 2015 3:06 PM
Points: 2,590, Visits: 1,685
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


Not all gray hairs are Dinosaurs!
Post #1454199
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse