开始使用免费开始使用

创建 PreventNewDiscounts 触发器

公司不希望普通用户添加折扣。只有销售经理可以执行该操作。

为防止此类更改,您需要创建一个名为 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);
编辑并运行代码