I have gone through different search and found many similar posts in which the solution was given to transform XML into Tabular format. Below is the sample data of a single row's column I'm attaching and also the basic query which I have done so far.
<DS_systeminfo>
<Systeminfo>
<Property>CurrentLanguage</Property>
<Property_value>en-US</Property_value>
</Systeminfo>
<Systeminfo>
<Property>Manufacturer</Property>
<Property_value>LENOVO</Property_value>
</Systeminfo>
<Systeminfo>
<Property>SerialNumber</Property>
<Property_value>789654</Property_value>
</Systeminfo>
<Systeminfo>
<Property>Caption</Property>
<Property_value>ATTT</Property_value>
</Systeminfo>
<Property>Manufacturer</Property>
<Property_value>LENOVO</Property_value>
</Systeminfo>
<Systeminfo>
<Property>WindowsDirectory</Property>
<Property_value>C:\WINDOWS</Property_value>
</Systeminfo>
and the query
is below:
SELECT SerialNumber,
Cast(SystemInfoXML AS XML).value('(/DS_systeminfo/Systeminfo/Property)[1]', 'varchar(100)') AS Caption,
Cast(SystemInfoXML AS XML).value('(/DS_systeminfo/Systeminfo/Property_value)[1]', 'varchar(100)') AS Value
FROM TerminalsDetail
This is fetching only first node's value , I want to select all the nodes dynamically in a single query , may be using cursor
.
the data given is of single row, I have more over 100 rows for which I need to convert to tabular format.
any kind suggestion will be helpful.