SqlServer-触发器
这两触发器比较精简,容易理解
1、简单触发器
create trigger [dbo].[triggerlog]
on [dbo].[users]
after update
as
begin
set nocount on;
insert into dbo.[log](logcontent) select '修改前:'+deleted.username+deleted.userrealname+'修改后:'+inserted.username+inserted.userrealname from deleted,inserted
end
2、触发器-包含类型转换
create trigger [dbo].[triggerlog]
on [dbo].[base_user]
after update
as
begin
-- set nocount on added to prevent extra result sets from
-- interfering with select statements.
set nocount on;
insert into [dbo].[log](logname) select '修改前:' +deleted.account+deleted.[password]+convert(varchar,deleted.coin)+'修改后:'+inserted.account+inserted.[password]+convert(varchar,inserted.coin) from deleted,inserted
-- convert(数据类型,值)
end
go
下一篇: 最让人不满意的中小企业管理方式