34,576
社区成员
发帖
与我相关
我的任务
分享
create trigger tr_t on 你的表名
for update
as
begin
insert yourtable
select *
from deleted
end
create trigger tr_t on 你的表名
for update
as
begin
insert yourtable
select *
from inserted
end
USE AdventureWorks;
GO
DECLARE @MyTableVar table(
EmpID int NOT NULL,
OldVacationHours int,
NewVacationHours int,
ModifiedDate datetime);
UPDATE TOP (10) HumanResources.Employee
SET VacationHours = VacationHours * 1.25
OUTPUT INSERTED.EmployeeID,
DELETED.VacationHours,
INSERTED.VacationHours,
INSERTED.ModifiedDate
INTO @MyTableVar;
--Display the result set of the table variable.
SELECT EmpID, OldVacationHours, NewVacationHours, ModifiedDate
FROM @MyTableVar;
GO
--Display the result set of the table.
--Note that ModifiedDate reflects the value generated by an
--AFTER UPDATE trigger.
SELECT TOP (10) EmployeeID, VacationHours, ModifiedDate
FROM HumanResources.Employee;
GO
create trigger tr_t on 你的表名
for update
as
begin
declare @n int
set @n=(select id from inserted )
print '你表中ID为'+rtrim(@n)+'已经修改了!!'
end