SQL Server - How do you create trigger on system
tables? - Feb 27, 2010 at 11:50 AM by Shuchi Gauri
How do you create trigger on system tables? What can be the reasons to create
trigger on system tables?
Reasons to create trigger on system tables:
-
One might need to be notified or take some action when a new object is created
or modified in sysobjects.
-
One might need to be notified or take some action when a new user is created or
modified in sysusers.
Creating trigger:
Use master
Go
Create trigger trigAbc on dbo.sysobjects for insert, update, delete as select
‘Hallo Welt’
SQL Server - How do you create trigger on system
tables? - May 05, 2009 at 22:00 PM by Rajmeet Ghai
How do you create trigger on system tables? What can be the reasons to create
trigger on system tables?
Even though creating triggers on system tables should be avoided, following are
the probable reasons why one would want to create triggers on system tables:
-
To take some action on an event like modification or creation of a new object.
-
To take some action on an event like modification or creation of a new user.
Even though a trigger may be created on a system table, it is less likely they
will be fired.
SQL Server - How do you create trigger on system
tables? - June 21, 2009 at 09:00 AM by Amit Satpute
Creating a trigger on system tables is done to:
Perform some action when a new object is created or an existing object is
modified.
Take some action when a user is added or modified.
To be fair, the build-in support in SQL Server 2000 for these reasonable
requirements is poor.
Some system tables accept triggers and some don't.
Example
use msdb
go
create trigger test on dbo.backupfile for insert, update, delete as select
'XYZ'
drop trigger system_trigger_test
At times triggers don’t get created as the permission to access the objects is
denied. In such cases trace needs to be used to find out the reason.
Also read
Answer - A batch is a group of one or more SQL statements. SQL
Server compiles the statements......
Even though creating triggers on system tables should be avoided, following are
the probable reasons why one would want to create triggers on system
tables.............
Table, Data types, Function, Index, Constraint, Rule, Default, Stored
Procedures, Trigger, View..........
Answer - CREATE DEFAULT, CREATE PROCEDURE, CREATE RULE, CREATE
TRIGGER, and CREATE VIEW statements....
|