sql server 2008 触发器

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

CREATE TRIGGER [inserted] ON [dbo].[Bussion]
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

猜你喜欢

转载自freellf.iteye.com/blog/1494089