我正在尝试更新Qty
存储在 SQL Server XML 列中的 XML 节点,没有发生错误,但我的字段没有得到更新。
请指教。谢谢。
从 SQL Server xml 列复制的 XML 数据:
<ArrayOfCampaignVoucher xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<CampaignVoucher>
<VouCode>Vouch002</VouCode>
<Qty>4</Qty>
</CampaignVoucher>
<CampaignVoucher xsi:nil="true" /></ArrayOfCampaignVoucher>
存储过程:
USE [c1]
GO
/****** Object: StoredProcedure [dbo].[Campaign_InsertRewardsVoucher] Script Date: 10/22/2011 23:33:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
*/
ALTER PROCEDURE [dbo].[Campaign_InsertRewardsVoucher]
@voucherXML XML, -- @voucherXML is the XML pass from my SQL server
AS
BEGIN
declare @changedVal int
set @changedVal = 4
UPDATE [Customers]
SET voucherXML.modify('replace value of (/CampaignVoucher/Qty/text())[1] with "0"')
WHERE voucherXML.value('(/CampaignVoucher/Qty)[1]', 'int') = @changedVal
END