|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Saturday, May 11, 2013 8:17 AM
Points: 460,
Visits: 2,521
|
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Today @ 5:10 PM
Points: 10,989,
Visits: 10,535
|
|
Another great instalment.
One thing for the section on inserting the contents of an XML variable when using 2005: there is a good workaround by Denis Ruckebusch here.
Paul White SQL Server MVP SQLblog.com @SQL_Kiwi
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: Monday, May 20, 2013 1:07 PM
Points: 18,733,
Visits: 12,332
|
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Today @ 5:42 PM
Points: 18,
Visits: 204
|
|
| Wow! Excellent stuff, Jacob.
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Saturday, May 11, 2013 8:17 AM
Points: 460,
Visits: 2,521
|
|
Thank you Paul, Jason and Brad. I am glad to know that you liked it.
.
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, May 26, 2010 12:31 AM
Points: 8,
Visits: 31
|
|
Hello jacob
The question is this: I need to add a progressive for each element of an XML document. I read your two interesting articles "XML Workshop 25" and "XML Workshop XVII - Writing a LOOP to process XML elements in TSQL" and merged the two.
The problem is this: Until I have a few XML elements from loop (say up to 10) all right, but increasing the processing is very slow so that I stop.
xml docoment:
<flsProSoc> <Accesso> <Identificativo>2008123456789000</Identificativo> <Erogatore> <CodiceIstituto>010ABAZZ</CodiceIstituto> </Erogatore> <Entrata> <Data>2008-03-18</Data> <Ora>09:30</Ora> </Entrata> <!-- many other XML elements and subelements XML --> </Accesso> ....................................... ....................................... </flsProSoc>
Code:
DECLARE @max INT, @i INT, @xml XML SELECT @xml= (SELECT * FROM OPENROWSET(BULK 'C:\MYXML.xml' , SINGLE_BLOB) as x) SELECT @max = @xml.query('<e> { count(/flsProSoc/Accesso) } </e>').value('e[1]','int') SET @i = 1 WHILE @i <= @max BEGIN SET @xml.modify(' insert element MyId {sql:variable("@i")} as first into (flsProSoc/Accesso[position()=sql:variable("@i")])[1] ') SET @i = @i + 1 END
I thank you in advance for your interest
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Saturday, May 11, 2013 8:17 AM
Points: 460,
Visits: 2,521
|
|
I think the performance is bad here for two reasons: loops and UNTYPED XML. In most cases, loops give bad performance. Since the XML document being processed is not TYPED XML, the processing overhead will be comparatively more.
.
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, May 26, 2010 12:31 AM
Points: 8,
Visits: 31
|
|
Hi Jacob Typed XML want to XSD schema associated, right? I try to see if it improves performance. Where do I specify the XSD file? There is another solution to my problem always returns within TSQL? Thanks again
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Saturday, May 11, 2013 8:17 AM
Points: 460,
Visits: 2,521
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Saturday, April 13, 2013 4:08 PM
Points: 2,
Visits: 202
|
|
Excellent article. I've been wondering on what is the best approach for updating an XML field data given another XML field with the same schema.
Thanks
|
|
|
|