sql xml
DECLARE @xml XML;
SET @xml = '<Root>
<Item name="entityType">ZBProductProfitsLossesTwo</Item>
<Item name="startDate"></Item>
<Item name="endDate"></Item>
<Item name="pageIndex">1</Item>
<Item name="pageSize">10</Item>
<Item name="SqlFilter"></Item>
<Item name="rows" Direction="Output"></Item>
</Root>';
create table #pp
(
name nvarchar(50),
value nvarchar(50),
Direction nvarchar(50)
)
insert into #pp
SELECT '@' + v.value('(@name)[1]', 'nvarchar(50)') AS NAME
,v.value('(.)[1]', 'nvarchar(50)') AS value
,ISNULL(v.value('(@Direction)[1]', 'nvarchar(50)'), 'Input') AS Direction
FROM @xml.nodes('//Root/Item') T(v)
set nocount off
declare @var nvarchar(max)=''
select @var=@var+','+name+' '+Direction from #pp
set @var=SUBSTRING(@var,2,len(@var));
drop table #pp
print @var
posted on 2013-07-02 17:27 RedFox(低调) 阅读(261) 评论(0) 收藏 举报
浙公网安备 33010602011771号