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