MulaiMulai sekarang secara 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.

Latihan ini adalah bagian dari kursus

Building and Optimizing Triggers in SQL Server

Lihat Kursus

Petunjuk latihan

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

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

-- 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;
Edit dan Jalankan Kode