如何将UPDATE外部应用转换为Update Left Join?

时间:2015-07-31 01:11:07

标签: sql sql-server

我在sql 2008上运行此查询,但我的客户端需要在sql 2000上运行。 有人可以帮我把这个查询转换成sql 2000吗?

Update cust set Balance = dv.balance 
From (SELECT hb.Balance,dv.custnum FROM [#custnumtbl] as dv 
OUTER APPLY (SELECT TOP 1 Balance,custnum FROM CLedger b 
WHERE b.CustNum = dv.custnum ORDER BY Pdate DESC) as hb) as dv 
where cust.CustNum = dv.custnum

2 个答案:

答案 0 :(得分:0)

我非常确定这等同于以下相关子查询:

Update cust
    set Balance = (SELECT TOP 1 cl.Balance
                   FROM [#custnumtbl] dv JOIN
                        Cledger b
                        ON b.CustNum = dv.custnum
                   WHERE dv.custnum = cust.CustNum
                   ORDER BY Pdate DESC
                  );

答案 1 :(得分:0)

SQL2000在视图中不支持# test_helper.rb include 'helpers/my_useful_module' module MyGem class Test < Minitest::Test include MyUsefulModule end end # my_test.rb include 'test_helper' module MyGem MyTest < Test end end

ORDER