Preventing server changes
The company is also asking you to find a method to prevent databases from being mistakenly deleted by employees.
After a detailed analysis, you decide to use a trigger to fulfill the request.
The trigger will roll back any attempts to delete databases.
Este exercício faz parte do curso
Building and Optimizing Triggers in SQL Server
Instruções do exercício
- Create a new trigger called
PreventDatabaseDelete
. - Attach the trigger at the server level.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
-- Create a trigger to prevent database deletion
CREATE TRIGGER ___
-- Attach the trigger at the server level
ON ___ ___
FOR DROP_DATABASE
AS
PRINT 'You are not allowed to remove existing databases.';
ROLLBACK;