Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Parse XML to table


Parse XML to table

Author
Message
Steven Willis
Steven Willis
Right there with Babe
Right there with Babe (731 reputation)Right there with Babe (731 reputation)Right there with Babe (731 reputation)Right there with Babe (731 reputation)Right there with Babe (731 reputation)Right there with Babe (731 reputation)Right there with Babe (731 reputation)Right there with Babe (731 reputation)

Group: General Forum Members
Points: 731 Visits: 1721
Comments posted to this topic are about the item Parse XML to table
Jonathan AC Roberts
Jonathan AC Roberts
SSChasing Mays
SSChasing Mays (604 reputation)SSChasing Mays (604 reputation)SSChasing Mays (604 reputation)SSChasing Mays (604 reputation)SSChasing Mays (604 reputation)SSChasing Mays (604 reputation)SSChasing Mays (604 reputation)SSChasing Mays (604 reputation)

Group: General Forum Members
Points: 604 Visits: 1858
I tried running it on a bit of xml that stores an order on our database.
It ran for over 6 minutes before I stopped it.
jcasement
jcasement
Grasshopper
Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)

Group: General Forum Members
Points: 14 Visits: 127
This only works for the most of trivial samples.
Academic and won't work for real world cases.
Try using it on over a gig of XML data and watch it blow up.
Jonathan AC Roberts
Jonathan AC Roberts
SSChasing Mays
SSChasing Mays (604 reputation)SSChasing Mays (604 reputation)SSChasing Mays (604 reputation)SSChasing Mays (604 reputation)SSChasing Mays (604 reputation)SSChasing Mays (604 reputation)SSChasing Mays (604 reputation)SSChasing Mays (604 reputation)

Group: General Forum Members
Points: 604 Visits: 1858
I just tried it on a bit of xml that had a DataLength of 13859 and it took 3:28 (3 minutes 28 seconds) to complete. I then tried it on another bit of xml with a datalength of 20030 and it took 22:47 (22 minutes) to complete and generated 993 rows. It would be nice if it were a bit quicker so it could be used in a reasonable amount of time.
lionfan91
lionfan91
SSCarpal Tunnel
SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)

Group: General Forum Members
Points: 4709 Visits: 429
I'll add to the slowness comments... it processed 11K of XML in a little over two minutes. I tried on a 141K block and it ran for 12 minutes before I gave up.



Steven Willis
Steven Willis
Right there with Babe
Right there with Babe (731 reputation)Right there with Babe (731 reputation)Right there with Babe (731 reputation)Right there with Babe (731 reputation)Right there with Babe (731 reputation)Right there with Babe (731 reputation)Right there with Babe (731 reputation)Right there with Babe (731 reputation)

Group: General Forum Members
Points: 731 Visits: 1721
Thanks all for the feedback. Every environment is different so it's hard to anticipate what kind of loads such a process might need to handle. In my use it was for relatively small XML files used by a web service.

I think the main problem is that it uses several levels of recursion within the CTEs. I'll see what I can do to streamline the process. Any suggestions are welcome. I'm always open to improving the code.

 
Ian (SSC)
Ian (SSC)
Grasshopper
Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)

Group: General Forum Members
Points: 18 Visits: 219
This is a nice bit of code on smaller chunks of XML.

It might also be worth adding exec "sp_xml_removedocument @idoc" to the end of the procedure to free up memory.
diklevich
diklevich
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 172
Not working for me.
SELECT @@VERSION


Microsoft SQL Server 2012 - 11.0.5058.0 (X64)
May 14 2014 18:34:29
Copyright (c) Microsoft Corporation
Developer Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)

When trying an example from the post it gives:
Msg 217, Level 16, State 1, Procedure ParseXMLtoTable, Line 63
Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32).

PS. Nevermind. I just run the whole code at once and examples just became a part of the procedure itself.
bauke.dijkstra
bauke.dijkstra
Forum Newbie
Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: General Forum Members
Points: 9 Visits: 23
i am missing or not seeing the place where to puth my path
i.e. C:\data.xml
Iwas Bornready
Iwas Bornready
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12334 Visits: 885
Thanks for the script.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search