update b
set a = (select count(列1) from 表2 ),b = (select sum(列2) from 表2 ),
from 表1 b
这个写法比只更新一列要慢一倍,有什么简化方法吗下面这种方法好象不行说错误update b
set (a,b) = (select count(列1),sum(列2) from 表2)
from 表1 b
谢谢大家
set a = (select count(列1) from 表2 ),b = (select sum(列2) from 表2 ),
from 表1 b
这个写法比只更新一列要慢一倍,有什么简化方法吗下面这种方法好象不行说错误update b
set (a,b) = (select count(列1),sum(列2) from 表2)
from 表1 b
谢谢大家
DECLARE @I INT
select @INT=count(列1) from 表2 update b
set a =@I,b = @I
from 表1 b
a = B.rowcnt,
b = B.rowsum
FROM tb1 AS A,
(SELECT COUNT(col1) AS rowcnt,SUM(col2) AS rowsum FROM tb) AS B;
select @INT=count(列1) from 表2 DECLARE @B INT
select @B=SUM(列2) from 表2 update b
set a =@I,b = @B
from 表1 b
select @I=count(列1) from 表2 DECLARE @B INT
select @B=SUM(列2) from 表2 update b
set a =@I,b = @B
from 表1 b
宝鸭名字都不打对,呼呼
set a = t.a,b = t.b
from 表1 b ,
(select count(列1) a,sum(列2) b from 表2) t
a
set
a = B.rowcnt,
b = B.rowsum
from
tb1 a,(select count(col1) rowcnt,sum(col2) rowsum from tb) B;
a
set
a = B.rowcnt,
b = B.rowsum
from
tb1 a,(select count(col1) rowcnt,sum(col2) rowsum from tb) B;
set a = count(列1) ,
b = sum(列2)
from 表1 b
,表2
update b
set a = (select rows from sysindexes where id=object_id('表2') and indid=0 ),b = (select sum(列2) from 表2 )
from 表1 b
;
with cte1 as
( select * from b,(select count(列1) rowcnt1,count(列2) rowcnt2 from 表2) B
)update cte1 set a=rowcnt1,b=rowcnt2
2:t-sql到目前为止还不支持行值构造器,虽然Ansi支持
会提示:无法绑定由多个部分组成的标识符 b.aaaupdate b
set a = t.a,b = t.b
from 表1 b ,
(select count(列1) a,sum(列2) b from 表2 where b.aaa = 1) t麻烦大家了
update b
set a = t.a,b = t.b
from 表1 b ,
(select count(列1) a,sum(列2) b from 表2 ) t
where b.aaa=1
试试
set a = t.a,b = t.b
from 表1 b ,
(select count(列1) a,sum(列2) b from 表2 where aaa = 1) t
把B给去掉.
set a = t.a,b = t.b
from 表1 b ,
(select count(列1) a,sum(列2) b from 表2) t
where b.aaa=1如果你的aaa在表1,这样.
set a = t.a,b = t.b
from 表1 b ,
(select count(列1) a,sum(列2) b from 表2 where aaa = 1) t
update b set b.a=a.a,b.b=a.b
from 表1 b,(select count(列1) a,max(列2) b from 表2) a
set a = t.a,b = t.b
from 表1 b ,
(select count(列1) a,sum(列2) b from 表2 where b.列3 = 列3) t 还是没解决哦,,,我条件里一定会有一个 B 的提示:无法绑定由多个部分组成的标识符 b.列3