insert into tb(a,b) values(val , val) 插入时用相同的值即可.或是使用触发器.
create table tb (id int,a int,b int)create trigger tb_ab on tb for insert,update as begin update tb set b=a.a from tb a,inserted b where a.id=b.id endinsert into tb(id,a) select 1,5select * from tbid a b 1 5 5update tb set a=6 where id=1select * from tbid a b 1 6 6
插入时用相同的值即可.或是使用触发器.
on tb
for insert,update
as
begin
update tb set b=a.a from tb a,inserted b where a.id=b.id
endinsert into tb(id,a) select 1,5select * from tbid a b
1 5 5update tb set a=6 where id=1select * from tbid a b
1 6 6