[导入]SQL语句之触发器
当对一个表进行insert delete update时执行的操作.
这个例子是当对info信息表添加时,将infoclass信息分类表的该分类的对应总信息条数加一操作
if(Exists(select * from sysobjects where name='info_insert' and xtype='tr'))
drop trigger info_insert
go
create trigger [info_insert]
on [info]
for insert
as
begin
declare @id int
select @id=clsid from inserted
update infoclass set num=num+1 where id=@id
end
类别:学习笔记 查看评论
文章来源:http://hi.baidu.com/honghu3000/blog/item/1cb08417f9e495064a90a7df.html