?? 第二個刪除型觸發(fā)器.sql
字號:
/*定義第二個刪除型觸發(fā)器*/
CREATE trigger t_products
ON products
FOR DELETE
AS
/*顯示信息代表觸發(fā)器執(zhí)行*/
PRINT 'DELETE trigger on the products table is executing '
/*聲明一個臨時變量用來存儲將要刪除表的順序*/
DECLARE @product_id char (4),
@mesg varchar (40)
SELECT @product_id=productid
FROM deleted
GROUP BY productid
IF @@rowcount = 0
BEGIN
PRINT 'no rows affected on the products table'
RETURN
END
/*刪除產(chǎn)品記錄*/
SELECT @mesg='deleting discounts for products' + @mesg
PRINT @mesg
DELETE discounts
WHERE productid=@product_id
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -