@manhng

Welcome to my blog!

Trigger

October 7, 2017 11:23

Sample Trigger

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TRIGGER [Admin_Permission]
ON DATABASE
FOR CREATE_TABLE, CREATE_VIEW, DROP_TABLE, DROP_VIEW, ALTER_TABLE
AS
PRINT 'You can not initialize, because you do not have rights. Please contact Administrator (Mr Duc) for permission. Thank you!'
ROLLBACK

GO

DISABLE TRIGGER [Admin_Permistion_by_Ducvx] ON DATABASE
GO

 

Server Trigger

You can see them here

select * from sys.server_triggers

To drop use this syntax

drop trigger trg_preventionDrop on all server

In Management Studio they are under the "Server Objects" -> "Triggers" node

Database Trigger

You can see them here

select * from yourdb.sys.triggers

To drop use this syntax

drop trigger trg_preventDeleteTable on database

In Management Studio they are under the "Databases" -> "yourdb" -> "Programmability" -> "Database Triggers" node

 

 

Categories

Recent posts