1、生成临时表 select * into #tmp -- 插入到临时表 from a,b,c,d -- 按需查询n个表结果2、将临时表中的多个字段更新到一张表 update yourtable set col1 = y.b, col2=y.c from #tmp y where y.id = yourtable.id
测试数据都舍不得给。 ;with t as( select ...... from tbl --你的查询语句 ) update 需要更新的表 set 需要更新的字段=t.对应的字段...... from t where t.标识字段=tbl.标识字段
select * into #tmp -- 插入到临时表
from a,b,c,d -- 按需查询n个表结果2、将临时表中的多个字段更新到一张表
update yourtable set col1 = y.b, col2=y.c
from #tmp y where y.id = yourtable.id
测试数据都舍不得给。
;with t
as(
select ...... from tbl --你的查询语句
)
update 需要更新的表
set 需要更新的字段=t.对应的字段...... from t where t.标识字段=tbl.标识字段