--看来确实不能直接用.改用这个吧.当然,需要你的表中有主键.create trigger t_insert on 表 after insert as insert into 另一个表 select a.* from 表 a inner join inserted b on a.主键=b.主键 go
--下面是例子:--创建测试表 create table t1(id int not null primary key,b text) create table t2(id int,b text)go --创建触发器 create trigger t_insert on t1 after insert as insert into t2 select a.* from t1 a inner join inserted b on a.id=b.id go--插入数据测试 insert into t1 values(1,'abc')--显示测试结果 select * from t1 select * from t2go --删除测试环境 drop table t1,t2
测试结果: id b ----------- ------------------------ 1 abc(所影响的行数为 1 行)id b ----------- ------------------------ 1 abc(所影响的行数为 1 行)
after insert
as
insert into 另一个表 select a.* from 表 a inner join inserted b on a.主键=b.主键
go
create table t1(id int not null primary key,b text)
create table t2(id int,b text)go
--创建触发器
create trigger t_insert on t1
after insert
as
insert into t2 select a.* from t1 a inner join inserted b on a.id=b.id
go--插入数据测试
insert into t1 values(1,'abc')--显示测试结果
select * from t1
select * from t2go
--删除测试环境
drop table t1,t2
id b
----------- ------------------------
1 abc(所影响的行数为 1 行)id b
----------- ------------------------
1 abc(所影响的行数为 1 行)