create trigger my_trig on tb1 for insert as begin insert into tb2 select '某已知的定值' , val from inserted --val为tb1某个字段刚插入你的值,你可以自己选择你需要的字段,另'某已知的定值' , val 的顺序你也可以自己指定. end
[code=] SQLCreate Trigger Tr_table1 on table1 For insert as Declare @v1 varchar, @v2 varchar Begin Select @v1 = a, @v2 = b From Inserted Insert into Table2(a,b) values(@v1,@v2) End [/code]
? insert into tb2 select '定值' , val from inserted
insert into tb2 select '已知的定值' , val from inserted
as
begin
insert into tb2 select '某已知的定值' , val from inserted
--val为tb1某个字段刚插入你的值,你可以自己选择你需要的字段,另'某已知的定值' , val 的顺序你也可以自己指定.
end
SQLCreate Trigger Tr_table1
on table1
For insert
as
Declare @v1 varchar,
@v2 varchar
Begin
Select @v1 = a, @v2 = b From Inserted
Insert into Table2(a,b)
values(@v1,@v2)
End
[/code]
insert into tb2 select '定值' , val from inserted