Stopping Database Deletion at Serer Level Using Trigger.
--This Trigger(DDL Triggger.Created at Server Level)stops deleting Database unexpectedly.
CREATE TRIGGER DontDeleteDatabase
ON ALL SERVER
AFTER DROP_DATABASE
AS
BEGIN
PRINT 'Are You sure you want to Delete this Database.To do so, Please disable the trigger and Try.'
ROLLBACK----This is very important if we forgot this.Databse will drop instantly.
END
CREATE TRIGGER DontDeleteDatabase
ON ALL SERVER
AFTER DROP_DATABASE
AS
BEGIN
PRINT 'Are You sure you want to Delete this Database.To do so, Please disable the trigger and Try.'
ROLLBACK----This is very important if we forgot this.Databse will drop instantly.
END
Comments