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
Author
Message
Posted Thursday, May 16, 2013 3:25 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, November 5, 2014 6:49 AM
Points: 114, Visits: 424
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
Post #1453384
Posted Thursday, May 16, 2013 3:35 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 8:31 AM
Points: 40,456, Visits: 36,912
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 2008, 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
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, November 21, 2014 10:15 AM
Points: 2,464, Visits: 1,551
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!
Post #1454199
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse