一条判断表Dv_Board中字段boardmaster 是否被更新的触发器

时间:2021-01-14 20:09:47

一条判断表Dv_Board中字段boardmaster 是否被更新的触发器。

然后把boardmaster 字段更新前后的之值插入到crpByBoard表中做记录。

 

crate TRIGGER [bakMaster]
on [dbo].[Dv_Board]
for update
as
begin
    if update(boardMaster)
    begin
        declare @bid int
        declare @master nvarchar(256)
        declare @change nvarchar(256)
        select @bid=boardid,@master=boardmaster from deleted d
        select @change=boardmaster from inserted
        insert into crpByBoard (boardID,boardMaster,remark) values(@bid,@master,@change)
    end

end