0
我有一些問題,我從互聯網上獲取此代碼,並將其改爲供我自己使用。我運行示例,它工作正常,沒有問題。在我改變它爲我的程序後,它不顯示任何錯誤,只是0行受影響。結果,xml列沒有任何返回。我希望得到一些提示。來自XML的SQL更新始終返回空值
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