0

I have a sql query to fetch values from an xml. Below is the structure of 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>

Query used is

SELECT name,descr
FROM OPENXML(@hDoc, 'workflow/meta')
WITH 
 (

name [varchar](255) '@name',
descr [varchar](255) '../meta'

)

I need to get a table with results

name                         |  descr
-----------------------------------------------------
jira.update.author.name            xyz 
jira.description                   Mobility Story Workflow
jira.updated.date                  1284423336959

The select query fetches only xyz in the descr column. Any workaround?

Roman Pekar
  • 107,110
  • 28
  • 195
  • 197
mhn
  • 2,660
  • 5
  • 31
  • 51
  • I have edited your title. Please see, "[Should questions include “tags” in their titles?](http://meta.stackexchange.com/questions/19190/)", where the consensus is "no, they should not". – John Saunders Aug 21 '13 at 19:19

1 Answers1

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)
Roman Pekar
  • 107,110
  • 28
  • 195
  • 197