|
发表于 2020-4-10 20:00:02
|
显示全部楼层
create table temp(ID int, 产品ID int, 时间 datetime, v1 int, v2 int, v3 int , v4 int, sums int)
create trigger auto_update on temp
for insert
as
update a set a.时间 = getdate() , a.sums = a.v1+a.v2+a.v3+a.v4 from temp a, inserted b where a.产品ID= b.产品ID
insert temp (产品ID) values(2001)
select * from temp |
|