sql server 如何为xml类型节点增加一个属性?
eg: <a></a> ===> <a id='1'></a>
如何为一个元素增加值?
eg: <a></a> ===> <a>1</a>另外,哪里有sqlserver中使用xquery全面一点的资料。。msdn上翻了老半天,,零零碎碎的一点。
多谢!!!!
eg: <a></a> ===> <a id='1'></a>
如何为一个元素增加值?
eg: <a></a> ===> <a>1</a>另外,哪里有sqlserver中使用xquery全面一点的资料。。msdn上翻了老半天,,零零碎碎的一点。
多谢!!!!
set @x = '<x></x>';SET @x.modify('insert text{"csdn"} as first into (/x)[1]')select @x;SET @x.modify('replace value of (/x/text())[1] with "liangck"');select @x;
declare @x1 xml='<a></a>';
set @x1.modify('insert text{"1"} into (/a)[1]');
select @x1;
/*
<a>1</a>
*/declare @x2 xml='<a></a>';
set @x2.modify('insert attribute id{"1"} into (/a)[1]');
select @x2;
/*
<a id="1" />
*/