Viewing 15 posts - 76 through 90 (of 140 total)
T_Peters (10/30/2012)
That works perfect! Thank you very much!Tim
No problem, thanks for the feedback.
I did notice that i left something unnecessary in the code from my testing :ermm:
You don't need the...
October 31, 2012 at 2:14 am
Hi,
Normally you can simply use the nodes() method to shred the xml and this will return you a nice dataset. However, with your example XML, I see that the data...
October 30, 2012 at 2:03 pm
To shred the xml to flat tables, you will need to use some of the xml data type methods and maybe a little bit of XQuery. the nodes() method will...
October 25, 2012 at 6:45 am
Personally I would use XQuery to do the transformation. I save xslt for the hardest of transformations, but to be honest, I have been able to do most things in...
October 9, 2012 at 1:29 am
Very good + clear question. thanks... nice way to start the week.
October 8, 2012 at 1:41 am
No you don't need to do that. That example query will work ok regardless of the number of actual repeats you get of GPSFixes or GPSFix in the XML message....
September 28, 2012 at 10:01 am
If both GPSFixes and GPSFix repeat then you'll need to have 2 x .nodes methods(). Here is an example using your xml as a base (i have stripped it back...
September 28, 2012 at 9:52 am
BTW: Choose better datatypes that I have in the query! shame on me !!
September 28, 2012 at 9:36 am
MM: Thanks for the /text() tip there.
photo1: try this to get the speed values
SELECT t.c.value('(Speed[@Type="Avg"]/text())[1]', 'varchar(20)') AS 'SpeedAvg'
, t.c.value('(Speed[@Type="Inst"]/text())[1]', 'varchar(20)') AS 'SpeedInst'
, t.c.value('(Speed[@Type="Max"]/text())[1]', 'varchar(20)') AS 'SpeedMax'
FROM @xml.nodes('/VehicleInfoMessage/GPSFixes/GPSFix') T(c)
September 28, 2012 at 9:30 am
You're welcome.
September 28, 2012 at 9:16 am
Hi. To strip out the DTD you can use the CONVERT function e.g.:
DECLARE @xmlVarchar VARCHAR(MAX)
SET @xmlVarchar = '<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE VehicleInfo SYSTEM "http://www.vehicleinfo.com/dconnect/DConnect.v2.0.dtd">
<VehicleInfoMessage Type="GPS">
<VIN>4444TCFEXB8543456</VIN>
<FleetId>421250</FleetId>
<MsgId>415583965696</MsgId>
<MessageTime>2012-09-28 13:27:16 GMT</MessageTime>
<MessageTimeUTF>1348838836</MessageTimeUTF>
<DeliveryStatus>Current</DeliveryStatus>
<GPSFixes NumFixes="1">
<GPSFix>
<FixTime>2012-09-28 13:27:10...
September 28, 2012 at 8:47 am
Great question.. I nearly fell into the trap of selecting answer two by not reading the question properly! Thanks.
September 27, 2012 at 1:20 am
As I mentioned previously, AFAIK, there is no real way to just strip out a namespace from an xml structure by using TSQL other than to cast the xml to...
September 19, 2012 at 12:23 pm
Viewing 15 posts - 76 through 90 (of 140 total)