0

好的..我确定我有一个大脑放屁的时刻..但由于某种原因我无法让这个更新工作。我有 2 个表,我非常想将信息从 8 列复制到另一个表的 8 列。..这是我到目前为止所拥有的

update a
set a.denialcharge_cost = b.denial_cost
    , a.epd_cost = b.early_default_payment
    , a.expeditecharge_cost = b.expeditecharge
    , a.duediligence_cost = b.duediligence
    , a.deskreview_cost = b.deskreview
    , a.servicing_cost = b.servicingcharge
    , a.mers_cost = b.merscharge
    , a.qcplans_cost = b.qcplans
from orderheader a 
inner join clients b
on a.prnt_id = b.id

我得到了错误

Msg 512, Level 16, State 1, Procedure UpdateOrderHeader, Line 13
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.

我在客户端中有 x 个客户..在 orderheader 中有 y 个订单..每个订单可以有 1 个客户..每个客户可以有多个订单...orderheader 中的 prnt_id 在客户表中具有 id....任何帮助将不胜感激...我正在尝试将 denial_cost、early_default_payment、expeditecharge、duediligence、deskreview、servicescharge、merscharge、qcplans 从客户复制到 orderheader

4

3 回答 3

2

根据对上一个问题的回答以及我们所做的所有其他故障排除,您似乎在某处遇到了触发器。尝试禁用它并运行更新。

于 2012-05-03T19:13:07.590 回答
0

类似的东西应该可以工作(带格式)

update orderheader
set denialcharge_cost = b.denial_cost, 
    epd_cost = b.early_default_payment,
    expeditecharge_cost = b.expeditecharge,
    duediligence_cost = b.duediligence,
    deskreview_cost = b.deskreview, 
    servicing_cost = b.servicingcharge,
    mers_cost = b.merscharge, 
    qcplans_cost = b.qcplans
from clients b 
where orderheader.prnt_id = clients.id
于 2012-05-03T17:02:55.823 回答
0

根据我对错误的理解,您尝试在某处仅获取一个结果,并且子查询返回的不仅仅是一个字段。

喜欢

select (select * from bb) as count from cc 给出错误

因为子查询从嵌套查询返回多个字段

于 2012-05-03T17:07:14.193 回答