`
freellf
  • 浏览: 8403 次
最近访客 更多访客>>
社区版块
存档分类
最新评论

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
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics