June 10, 2010 at 6:25 am
Hi All
I am having an XML packet as shown below, when i try to select value using the SQL below i am always getting null as a value, can any one point me out where i am making a mistake, i am been stuck with this.
Declare @X XML
Select @X='<?xml version="1.0" encoding="ISO-8859-1"?>
<CONTENT>
<PROVIDER>ABC</PROVIDER>
<GAME>Poker</GAME>
<MATCH_TITLE>News</MATCH_TITLE>
<TEAMS_INVOLVED>NewsStart</TEAMS_INVOLVED>
<EVENT_TYPE>Poker UPDATES</EVENT_TYPE>
<CLIENT_ID>000000</CLIENT_ID>
<ALERTTEXT>This is what i wnat to get </ALERTTEXT>
<TIMESTAMP>10 May 2010 15:05:35</TIMESTAMP>
</CONTENT> '
WITH XMLNAMESPACES(
DEFAULT 'urnchemas-microsoft-comqlqlRowSet2'
)
SELECT x.value('ALERTTEXT[1]','varchar(3999)') from @x.nodes('/CONTENT/PROVIDER')v(x)
All i need to get is the Alerttext tab,
Thanks in advance for your help
Cheers
🙂
June 10, 2010 at 9:41 am
Two minor fixes: 1) remove the namespace declaration since this is an untyped xml document and 2) remove the "/PROVIDER" from your nodes declaration since this tag is closed before.
--;WITH XMLNAMESPACES(
--DEFAULT 'urnchemas-microsoft-comqlqlRowSet2'
--)
SELECT x.value('ALERTTEXT[1]','varchar(3999)') from @x.nodes('/CONTENT')v(x)
June 10, 2010 at 10:30 am
Thanks Imu , It worked a magic
June 10, 2010 at 10:40 am
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply