create table t1(id int identity(1,1),val varchar(10))
create table t2(t1id int)
go
create trigger setsumidtot2
on t1
for insert
as
insert into t2 select id from inserted
go
insert into t1(val) values('abc')
select * from t2
/*
t1id
-----------
1
++ ------其他解决方案-------------------- 用触发器就可以了 ------其他解决方案-------------------- 一个存储过程就是执行一个批啊。你这功底也太》。。。。 ------其他解决方案-------------------- 用触发器吧,10楼的做法应该可行
create table t1(id int identity(1,1),val varchar(10))
create table t2(t1id int)
go
create trigger setsumidtot2
on t1
for insert
as
insert into t2 select id from inserted
go
insert into t1(val) values('abc')
select * from t2 ------其他解决方案--------------------