hyadijxp 发表于 2016-10-31 04:03:10

sql server 2008 触发器

library数据库中有一个book表,现在要在此表上创建一个 ”before行级触发器“
功能:检测插入book表的每一条记录,如果图书价格小于40元则更改为40元,大于40元得图书不作任何改变
book(book_id,book_name,price,press)

CREATE TRIGGER ON .
FOR INSERT
AS
begin
declare @price money,@BID int
select @BID=Book_ID from inserted
select @price=price from inserted
if @price<40
update Bussion set price=40 where Book_ID=@BID
end
页: [1]
查看完整版本: sql server 2008 触发器