Solved

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

Posted on 2010-11-17
1
1,029 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
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

706 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now