sql server update触发器


--判断名称是否已存在,不建议,万一删了别人创建的呢
if (object_id('tgr_classes_update', 'TR') is not null)
    drop trigger tgr_classes_update

--查询看是否存在
select object_id('tgr_classes_update', 'TR');

--创建update触发器
create trigger tgr_classes_update
on classes
    for update
as
    declare @oldName varchar(20), @newName varchar(20);
    --更新前的数据
    select @oldName = name from deleted;
    --更新后的数据
    select @newName = name from inserted;
    
go

 

 

参考:https://www.cnblogs.com/Brambling/p/6741666.html

https://www.cnblogs.com/hoojo/archive/2011/07/20/2111316.html

 

触发器中获取客户端ip和名称 https://blog.csdn.net/ksrsoft/article/details/8457195

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM