Solved

CLR "save to file" procedure erroring in SQL Server 2005 SP3

Posted on 2010-11-17
1
1,045 Views
Last Modified: 2012-05-10
I'm using a CLR procedure (which I've called "writetofile") to allow SQL server to generate xml and save to file.   The procedure is based on the code at http://www.sqldbatips.com/showarticle.asp?ID=23

I'm using the procedure in a query which produces about 20 lines of XML per record retrieved and then saves the XML document to file.  The query works fine if I initially select the top 1,000 records (to produce around 20,000 lines of XML) but errors on around 10,000 records or more.  My results need to include around 60,000 records.  The query errors with the following error message:

Msg 6532, Level 16, State 49, Procedure writetofile, Line 0
.NET Framework execution was aborted by escalation policy because of out of memory.
System.Threading.ThreadAbortException: Thread was being aborted.
System.Threading.ThreadAbortException:
   at System.Data.SqlTypes.SqlChars.get_Value()
   at System.Data.SqlServer.Internal.XvarWlobStream.GetCharArray()
   at System.Data.SqlServer.Internal.XvarWlobStream.GetString()



I've found a hotfix which looks relevant to this but cannot install it as I have SP3 and it is designed for SP1.  See the following link for details of the hotfix:  http://support.microsoft.com/kb/928083

I've downloaded the Hotfix (several distinct executables which need to be installed in order).
When it comes to installing the hotfix, I'm falling at the first hurdle - when I run the first executable, it advises that is designed for SP1 and my version of Sql Server 2005 is at SP3.  It suggests I download a version of the hotfix for SP3. - which I cannot locate.


Any ideas for how I'd get some solution to leave me able to write a large amount of text (XML) to file as part of a SQL procedure?
0
Comment
Question by:Beamson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 51

Accepted Solution

by:
Mark Wills earned 250 total points
ID: 34161607
check : http://support.microsoft.com/kb/969962 
in particular : try giving more memory to SQL CLR by increasing the 'MemToLeave' or 'Non buffer pool memory' to 384 MB
can also check using CLR profiler : http://msdn.microsoft.com/en-us/library/ff650691.aspx

alternatively, create a new stored procedure and emulate your own "queue" by populating say a thousand rows at a time and appending to your output file, or some other logical grouping (unless it must be the one xml file)

0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question