473,513 Members | 2,290 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL Server 2005 'Insufficient Memory to run the query'

radcaesar
759 Recognized Expert Contributor
We are Running a .sql script which was created by tablediff.exe using SQLCMD

The script execution fails with the ' 701: There is insufficient system memory to run this query. ' Exception.

The following was the SQL Server Configuration


* Operating System: Windows Server 2003
* Database : SQL Server 2005 Standard Edition SP2
* Main Memory: 4GB
* Virtual Memory: 6GB
* Processors: 2 nos (Intel XEON 1.6 GHz)

Since, we are replicating a Database from a staging database, we are using the tablediff.exe.

The Script file which was created by the tablediff will be at the maximum size of 30MB.

The following are the SQL Server Settings which we are using now,


* Min Server Memory: 0
* Max Server Memory: 2147483647
* Min Memory Per Query: 2048
* AWE Enabled: No


Any ideas on where is the issue ?
Oct 31 '07 #1
13 8004
iburyak
1,017 Recognized Expert Top Contributor
This error usually is not about a size.
It is usually when server is trying to do something in infinite loop.
If you have a script that you run try commenting out parts of this script and find out which part is not working.

Good Luck.
Nov 4 '07 #2
radcaesar
759 Recognized Expert Contributor
The sync script was created by the TableDiff utility. If the record count in that script is below 20,000, then no problems there. But it fails on huge counts like 60,000. I don't think that there will be a way for infinite loop run.
Nov 6 '07 #3
iburyak
1,017 Recognized Expert Top Contributor
http://support.microsoft.com/kb/912439
Nov 6 '07 #4
radcaesar
759 Recognized Expert Contributor
Hi,
This is the first fix i had tried and my production server's SP are up to date (Currently SP2).

I was confused that why it had thrown this exception after the fix was installed ? Any Suggestions ?
Nov 11 '07 #5
iburyak
1,017 Recognized Expert Top Contributor
Without seeing your script it is hard to guess what you are doing and where the problem is.

As I said it looks like something is taking too much memory and not releasing it on time.
Nov 12 '07 #6
radcaesar
759 Recognized Expert Contributor
Yes Exactly,

I found this cause some 2 weeks back itself. But there is no way i have to execute that script with 7 lakhs insert and updates using SQLCMD.

The sp which i used is below,


Expand|Select|Wrap|Line Numbers
  1. USE [ODS]
  2. GO
  3. /****** Object:  StoredProcedure [dbo].[sp_TableDiff4]    Script Date: 11/12/2007 05:58:32 ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. ALTER PROCEDURE [dbo].[sp_TableDiff4]
  9.     -- Add the parameters for the stored procedure here
  10.     (@sourceTable varchar(100), 
  11.     @targetTable varchar(100), 
  12.     @filepath varchar(100))
  13. AS
  14. BEGIN
  15.         DECLARE @sTableDiff nvarchar(1000)
  16.         DECLARE @sPath nvarchar(100)
  17.         DECLARE @sTableName nvarchar(40)
  18.         DECLARE @a nvarchar(50)
  19.         DECLARE @sSQLCMD nvarchar(100)
  20.         SET @sTableDiff= ' "C:\Program Files\Microsoft SQL Server\90\COM\tablediff" -sourceserver GRSRV4 -sourceuser username -sourcepassword pwd -sourcedatabase ODS-STG -sourcetable ' + @sourceTable + ' -destinationserver GRSRV4 -destinationuser username -destinationpassword password -destinationdatabase ODS -destinationtable ' + @targetTable + ' -f '+@filepath 
  21.         PRINT @sTableDiff
  22.         EXEC XP_CMDSHELL @sTableDiff
  23.         SET @sTableName = @sourceTable
  24.         PRINT @sTableName
  25.         SET @sPath = 'd:\' + @sTableName
  26.         SET @sPath = @filepath
  27.         SET @sSQLCMD = 'sqlcmd -s GRSRV4 \SQL -U username -P pwd -d ODS -i ' + @sPath
  28.         PRINT @sSQLCMD
  29.         EXEC XP_CMDSHELL  @sSQLCMD
  30.         SET @a = 'del ' + @sPath
  31.         PRINT @a
  32.         EXEC XP_CMDSHELL @a
  33. END
  34.  
In the above code, the sql cmd acquires memory to execute the 7L+ records.

Is there any other ways to release the acquired memory manually in our code i.e in the above sp ?
Nov 12 '07 #7
iburyak
1,017 Recognized Expert Top Contributor
You know what, I had similar problem a long time ago.
I had a DLL and because I had to call it multiple times it made memory overflow. I had to reboot my Server to proceed.
What happened was DLL stayed in server memory and with each call it loaded a new instance of the same DLL. I put this DLL under COM object and it started controlling environment, if I called the same DLL again it provided the same already loaded into memory instance instead of loading a new one. I never had this problem since. I think you should put both executables (tablediff and sqlcmd) under COM control which could solve your problem.

Hope it helps.
Good Luck
Nov 13 '07 #8
radcaesar
759 Recognized Expert Contributor
I called it through a stored procedure and a T-SQL script. I Was not using any languages like c# to make a dll and use it. Now app is in production and its hard to make those changes.

Any other ways to release the memory ?
Nov 13 '07 #9
iburyak
1,017 Recognized Expert Top Contributor
I don’t think you understood what I was talking about.

Go to your server, click Start – Run – type mmc, press enter.
Go to File – Add/Remove Snap-in
Press Add button and choose Component Service.
Press Add, Close, OK.
Expend everything to vew COM+ Applications
.
This is what I was talking about. You should put programs you are calling from your procedure under control of this object which will control memory usage and protect memory overflow.

Good Luck.
Nov 13 '07 #10
radcaesar
759 Recognized Expert Contributor
Thanks a lot, Let me try this....

I don’t think you understood what I was talking about.

Go to your server, click Start – Run – type mmc, press enter.
Go to File – Add/Remove Snap-in
Press Add button and choose Component Service.
Press Add, Close, OK.
Expend everything to vew COM+ Applications
.
This is what I was talking about. You should put programs you are calling from your procedure under control of this object which will control memory usage and protect memory overflow.

Good Luck.
Nov 15 '07 #11
radcaesar
759 Recognized Expert Contributor
Here i have a problem.

When i try to install, it requests for .MSI or .PAK file. But mine are all T-SQL and Stored Procedure.

The problem where i got is the SQLCMD.EXE (This is the one which was responsible for executing the scripts).

How can i add this in COM+ ?

I don’t think you understood what I was talking about.

Go to your server, click Start – Run – type mmc, press enter.
Go to File – Add/Remove Snap-in
Press Add button and choose Component Service.
Press Add, Close, OK.
Expend everything to vew COM+ Applications
.
This is what I was talking about. You should put programs you are calling from your procedure under control of this object which will control memory usage and protect memory overflow.

Good Luck.
Nov 15 '07 #12
iburyak
1,017 Recognized Expert Top Contributor
First program should be in this path according to your script.

C:\Program Files\Microsoft SQL Server\90\COM\tablediff.exe

Second program you should search for using Windows Search utility or better you should go to Registry and search for this keyword and it should show you where it is registered from.


sqlcmd.exe


Good Luck.
Irina.
Nov 15 '07 #13
radcaesar
759 Recognized Expert Contributor
Hey,
I Was unable to add that executable (sqlcmd.exe) into the COM+ service since it doesn't accept exe files. It only accepts .msi and .pak files (i.e To install pre-build applications it ask for .msi and .pak files but mine was executable).

Any workarounds ?
Nov 26 '07 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

0
4094
by: AlessanBar | last post by:
Hello Friends !! I have a strange problem, and I need to know what would be the source of this. I have a laptop computer with the following configuration: Pentium III Brand : Toshiba Speed :...
5
1606
by: hishamfangs | last post by:
Hi guys! I'm facing a problem and I can't quite figure it out! I have created a table on SQL Server 2000 to store call records. We get about 250,000 calls a day, and the most frequently used...
16
2853
by: Justin Lazanowski | last post by:
Cross posting this question on the recommendation of an I have a .NET application that I am developing in C# I am loading information in from a dataset, and then pushing the dataset to a grid,...
6
2120
by: sathyashrayan | last post by:
Following are the selected thread from the date:30-jan-2005 to 31-jan-2005. I did not use any name because of the subject is important. You can get the original thread by typing the subject...
6
1756
by: mike | last post by:
Help; Im New with a company and the sql server is maxing out the cpu's We have 3 web servers load balanced.... large volume of data the current Properties Computer: 4 amd 2.88 processors 4...
15
2398
by: =?Utf-8?B?RWxpb3Ro?= | last post by:
I try to install Windows Services but it show this error during the installation process, "Insufficient System resources exist to complete the requested service." I created this Services in VB...
0
12870
Coldfire
by: Coldfire | last post by:
Since i cannot show the differences in a two-column like table. I am first putting MS SQL Server 2005 and then MySQL 5.x. MS SQL Server 2005 Brief Overview - SQL Server is a full-fledged...
0
2256
by: mauler05 | last post by:
I have scheduled a SSIS package to run repeatedly by creating a scheduled SQL job that runs every minute . After every hour the packgae fails with the following error Description:...
5
6307
by: marshmallowww | last post by:
I have an Access 2000 mde application which uses ADO and pass through queries to communicate with SQL Server 7, 2000 or 2005. Some of my customers, especially those with SQL Server 2005, have had...
0
7269
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7177
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7559
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5701
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3248
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3237
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
470
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.