日期:2014-05-17 浏览次数:20613 次
--1. 建日志表
create table tblog(objectID int,HeatTime datetime)
create trigger tri_U
on tb
after update
as
begin
if update(Heat)
begin
insert into tblog(objectID,HeatTime)
select ID,getdate() from inserted
end
end
-- 2. 查询日志表
select * from tblog
--1. 建日志表
create table tblog(objectID int,Heat int, newHeat int, HeatTime datetime)
GO
create trigger tri_U
on tb
after update
as
begin
if update(Heat)
begin
insert into tblog(objectID,Heat,newHeat,HeatTime)
select ID,D.Heat,I.Heat,getdate()
from INSERTED I
INNER JOIN DELETED D
ON I.ID = D.ID
WHERE I.Heat = d.Heat + 1 OR i.Heat = D.Heat - 1
end
end
GO
-- 2. 查询日志表
select * from tblog