日期:2014-05-17 浏览次数:20561 次
insert into HBTrigger_EnglishNews select id, 'Update', @updateFields from Inserted
Create Trigger HBTrigger_EnglishNews_Update
On EnglishNews
for Update
As
DECLARE @updateFields nvarchar(4000) //声明一个变量
set @updateFields = ''
if Update(GroupId) //下边都是记录更新的字段
begin
set @updateFields = @updateFields + 'GroupId,'
end
if Update(SiteId)
begin
set @updateFields = @updateFields + 'SiteId,'
end
if Update(Time)
begin
set @updateFields = @updateFields + 'Time,'
end
if Update(Title)
begin
set @updateFields = @updateFields + 'Title,'
end
if Update(Content)
begin
set @updateFields = @updateFields + 'Content,'
end
if @updateFields <> ''
begin
insert into HBTrigger_EnglishNews select id, 'Update', @updateFields from Inserted
end
select id, 'Update', @updateFields from Inserted