Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

XML Query

$
0
0

Hi All,

I have a table with xml column as below

<Description xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Parameters>
    <TimeZoneId>Eastern Standard Time</DeviceTimeZoneId>
    <ParameterType>DateTime</ParameterType>
    <ParameterValue>08/24/2009 22:24:30.100</ParameterValue>
  </Parameters>
  <Parameters>
    <ZoneId>Eastern Standard Time</DeviceTimeZoneId>
    <ParameterType>DateTime</ParameterType>
    <ParameterValue>08/24/2009 22:24:39.101</ParameterValue>
  </Parameters>
</Description>

I want to display other column along with values of <ParameterValue> (which is  08/24/2009 22:24:30.100 and 08/24/2009 22:24:39.101)

I wrote the below query and its returning null values. The name of the column is Description

WITH XMLNAMESPACES ('http://www.w3.org/2001/XMLSchema-instance' AS ns)
SELECT TOP 3 name,
Description.value('(/ns:Description/ns:Parameters/ns:ParameterValue)[1]', 'varchar(50)') AS Date1,[Description]

FROM Tab1

ANy pointers on how can I get the values. I tried different options but didn't help in getting the results.

Raj


Raj


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>