0
我有以下在Sql服務器中定義的映射。用另一個xml中的映射替換屬性的值?
declare @map xml = '<Maps><Map From="1" To="2"/><Map From="3" To="4" /></Maps>';
我將需要改變屬性Id
下面的(示例)xml使用映射的值。然而,根元素可以是任何東西,我想保留所有其他屬性。
declare @x xml;
set @x = '<XX><Value Id="1" OtherAttrs="..." /><Value Id="3" /></XX>';
-- Expect <XX><Value Id="2" OtherAttrs="..." /><Value Id="4" /></XX>
set @x = '<YY><Value Id="3" /><Value Id="1" OtherAttrs="..." /></YY>';
-- Expect <YY><Value Id="4" /><Value Id="2" OtherAttrs="..." /></YY>
select @x.query('...') -- How to write the xquery?
如何編寫xquery腳本?
如果我只有兩種根元素<XX>
和<YY>
會怎麼樣?
這是一個錯字,我修好了。謝謝。 – ca9163d9