if object_id('tb') is not null
begin
drop table tb
end
go
if object_id('tb2') is not null
begin
drop table tb2
end
go
create table tb(id int,name varchar(64),sex varchar(2))
create table tb2(id int,name varchar(64))
gocreate trigger t_i
on tb
for insert
as
begin
insert into tb2
select id,name from inserted
end
goinsert into tb
select '1','小明','男'select * from tb
select * from tb2

解决方案 »

  1.   

    create table tb(id int,name varchar(10),sex varchar(10))
    create table ta(id int,name varchar(10),num int)
    create trigger tri_tb
    on tb
    for insert
    as
    begin
    insert into ta(id,name) select id,name from inserted
    endinsert into tb select 2,'小黄','男'select * from taid name num
    2 小黄 NULL
      

  2.   

    create table a(id int,name varchar(10),sex varchar(10))
    insert into a select 1,'小明','男'create table b(id int,name varchar(10),num varchar(10))--创建触发器
    create table tri_a on a for insert
    as
    insert into b select * from insert
    go--测试:
    insert into a select 2,'小黄','男'
    --查看
    select * from b