前期准备:
create table Nums(X int);
create table T(X int);
go
目的:把对表Nums的insert | delete | update 反映到T表中。
---------------------------------------------------------------------------------------------------------------------------------------------
insert :
insert into Nums(X)
output inserted.X #记得它在列表之后
into T(X)
values(1),(2),(3);
deleted:
delete Nums
output deleted.X#它在表名之后
into T(X);
go
update:
update Nums
set X = 100
output inserted.X#它在set 之后
into T(X);
go