I have a table column consist with the XML files. I want to read XML data and display it.
I come up with the following code. But it read only one row in the column want to display other XML data also
declare @xml xml
select @xml = event_data_XML from #temp
SELECT * FROM (
SELECT
CAST(f.x.query('data(@name)') as varchar(150)) as data_name,
CAST(f.x.query('data(value)') as varchar(150)) as data_value
FROM @xml.nodes('/event') as t(n)
CROSS APPLY t.n.nodes('data') as f(x)) X
PIVOT (MAX(data_value) FOR data_name IN (NTDomainName, DatabaseName, ServerName)) as pvt
Output should be like this(NTDomainName, DatabaseName, ServerName are xml data)