This is the sample of xml in my table column;
Table name t005
, column name ACTIVITYDETAIL
, data type xml
.
Sample of xml
<root>
<Parameter>
<Param>SearcgBy</Param>
<Value>ALL</Value>
</Parameter>
<Parameter>
<Param>SearchText</Param>
<Value>SA</Value>
</Parameter>
</root>
Now I want output as
Param value
SearchBy ALL
SearchText SA
I tried so many ways and here is my last try.
SELECT
p.value('(./Parameter/node())[1]', 'VARCHAR(8000)') as firstName,
p.value('(./Parameter/node())[2]', 'VARCHAR(8000)') as lastName
FROM
t005
CROSS APPLY
ACTIVITYDETAIL.nodes('/root') t(p)
Please help me.