0

我有一点问题,我从互联网上获得了这段代码,我修改它以供我自己使用。我运行示例,它工作正常,没问题。在我为我的程序更改它之后,它没有显示任何错误,只有0 行受到影响。结果,xml 列什么也没返回。我希望得到一些提示。

declare @input XML 

set @input = '<?xml version="1.0" standalone="yes"?>
<NewDataSet>
  <CurrencyTransact>
<BCurrencyCode>USD</BCurrencyCode>
<StockBalance>18000.00</StockBalance>
</CurrencyTransact>
<CurrencyTransact>   
<BCurrencyCode>MYR</BCurrencyCode>
 <StockBalance>30000.00</StockBalance>
</CurrencyTransact>

'

;with GrabXML AS
 (
  select
       CurrencyBal.value('@BCurrencyCode', 'varchar(10)') as 'BCurrencyCode',
       CurrencyBal.value('@StockBalance', 'decimal(18,2)') as 'StockBalance'
       from
       @input.nodes('/NewDataSet/CurrencyTransact') as n(CurrencyBal)
)

update dbo.Currency
set StockBalance = g.StockBalance
from GrabXML g
where dbo.Currency.CurrencyCode = g.BCurrencyCode
4

1 回答 1

1

我只是更改了这条线以使其正常工作。问题解决了!

   CurrencyBal.value('(BCurrencyCode)[1]', 'varchar(10)') as 'BCurrencyCode',
   CurrencyBal.value('(StockBalance)[1]', 'decimal(18,2)') as 'StockBalance'
于 2015-10-05T21:56:34.813 回答