AnSharp
AnSharp

Reputation: 21

TRIGGER on DATABASE after insert SQL Server

I need to create a trigger on SQL database DB1 that fires when one or more row has been inserted in table T1.

The problem is that the table where i need the trigger could be drop and re-created in a second time, so, if i write the trigger on table T1 this would be dropped too.

what's the way to do that?

Upvotes: 0

Views: 77

Answers (1)

Craig Foster
Craig Foster

Reputation: 109

You could create a DDL trigger that would recreate your trigger on table T1.

Maybe have the DDL trigger fire on create table statement, check if your T1 has been created, and, if so, recreate the trigger.

Upvotes: 2

Related Questions