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?

1

1 Answer 1

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.