IniziaInizia gratis

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.

Questo esercizio fa parte del corso

Building and Optimizing Triggers in SQL Server

Visualizza il corso

Istruzioni dell'esercizio

  • Create a new trigger called PreventDatabaseDelete.
  • Attach the trigger at the server level.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

-- 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;
Modifica ed esegui il codice