Creating XML via SQL Server and receive error with larger dataset

When running with less than 25,000 records the XML generation runs fine but when the data set exceeds 25K records I get this error.  Does anyone have an idea why this might be.  The location in the procedure that is said to fail changes in direct relationship to the amount of data being processed.  The structure  of the XML is as below.
          <Item Attributes..../>
          <Item Attributes..../>
          <Item Attributes..../>
          <Item Attributes..../>
          <Item Attributes..../>

Open in new window

Sometimes it fails at in Stock sometimes in Despatch.  

Msg 6833, Level 16, State 1, Procedure PI_AppendTransmissionTable_V2, Line 51
Who is Participating?
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
I fear I have bad news in regards to that the MS XML components are not really good for very large XML ... you will need to generate the XML outside of SQL...
listening ...
Anthony PerkinsCommented:
Please post the relevant section of your code, but I suspect Guy is right on this.
AlyantoAuthor Commented:
Thanks Guy, I believe you have confirmed what I feared.  At 25k records with 4 nesting levels size is propabably the issue.  I have gone for a scripting solution  and to be honest the performance on the same data with the same structure is a vast improvement.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.