Solved

SQL XML Parse

Posted on 2015-02-05
1
92 Views
Last Modified: 2015-02-08
How to query to get value of xml element when shown as below.
 
I have this in an xml doc . I can query and get any value successfully however  this returns a null every-time, does this require special handling while querying XML.


I have tried OpenXml and node() function everything returns NULL...
doc.col.value('ListPrice[1]', 'float') Price   --RETURNS NULL

 
<ListPrice Type="FLOAT" CurrencyCode="USD">139900.00</ListPrice>

Open in new window

0
Comment
Question by:leadcodev
1 Comment
 
LVL 12

Accepted Solution

by:
Habib Pourfard earned 500 total points
Comment Utility
it works for me:
DECLARE @XMLData XML = '<ListPrice Type="FLOAT" CurrencyCode="USD">139900.00</ListPrice>'
SELECT @XMLData.value('ListPrice[1]','float')

Open in new window

0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now