開始使用免費開始

建立 PreventNewDiscounts 觸發程序

公司不希望一般使用者新增折扣。只有 Sales Manager 可以這麼做。

為了防止這類變更,你需要建立一個名為 PreventNewDiscounts 的新觸發程序。

這個觸發程序應該掛載在 Discounts 資料表上,並阻止將新列加入該表。

本練習屬於課程

在 SQL Server 建立與最佳化觸發程序

檢視課程

練習說明

  • 在 Discounts 資料表上建立觸發程序 PreventNewDiscounts。
  • 將觸發程序設定為阻止任何新列被加入 Discounts 資料表。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

-- Create a new trigger
___ ___ ___
ON ___
___ ___ ___
AS
	RAISERROR ('You are not allowed to add discounts for existing customers.
                Contact the Sales Manager for more details.', 16, 1);
編輯並執行程式碼