我有一个SQL查询来从xml中获取值。下面是xml的结构
<workflow>
<meta name="jira.update.author.name">xyz</meta>
<meta name="jira.description">Mobility Story Workflow</meta>
<meta name="jira.updated.date">1284423336959</meta>
.
.
</workflow>
使用的查询是
SELECT name,descr
FROM OPENXML(@hDoc, 'workflow/meta')
WITH
(
name [varchar](255) '@name',
descr [varchar](255) '../meta'
)
我需要一张结果表
name | descr
-----------------------------------------------------
jira.update.author.name xyz
jira.description Mobility Story Workflow
jira.updated.date 1284423336959
select查询仅在descr列中提取xyz。任何解决方法?
答案 0 :(得分:1)
select
t.c.value('@name', 'nvarchar(max)') as name,
t.c.value('text()[1]', 'nvarchar(max)') as descr
from @data.nodes('workflow/meta') as t(c)