为什么会发生此错误:此查询上的Msg 512 .. Subquery returned more than 1 value
?
update [MEDC_MDC].[dbo].[Readings]
set [AccountNo] =
(select site_identifier
from [MEDCBSQL01.EHC.COM.OM].[orion_ehc_medc].[dbo].[v_party_acct2] a
Where active_meter_number in (select meterno from [MEDC_MDC].[dbo].[Readings]
where service_type <> 'W' and accountno is null) )
where accountno is null
答案 0 :(得分:0)
不能保证您的子查询返回单个值,因此请对其进行修改并确保查询返回单个值。
一个选项是添加 TOP 1 :
update [MEDC_MDC].[dbo].[Readings]
set [AccountNo] =
(select TOP 1 site_identifier
from [MEDCBSQL01.EHC.COM.OM].[orion_ehc_medc].[dbo].[v_party_acct2] a
Where active_meter_number in (select meterno from [MEDC_MDC].[dbo].[Readings]
where service_type <> 'W' and accountno is null) )
where accountno is null