Solved

how to run a large SQL Query?   "Insufficient memory"

Posted on 2013-06-05
9
552 Views
Last Modified: 2013-06-05
I have a 50MB .sql file.  It loads easily enough into SQL Management studio but I cannot execute it, it spits out an error that there is insufficient memory to parse the script.   Any ideas how I can run this?

SQL 2008
0
Comment
Question by:arthurh88
[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
  • 4
  • 3
  • 2
9 Comments
 
LVL 20

Expert Comment

by:dsacker
ID: 39223741
Just guessing here: If you have embedded INSERT statements, why not change your processing to load your data into a text file and BCP it into SQL.

I've been in DBA and SQL work for over 35 years, and I have yet to write a SQL file that has reached 1MB. What are you doing that must make this 50MB?
0
 
LVL 17

Expert Comment

by:Kent Dyer
ID: 39223746
Couple of things that come to mind..

Split the script into "bite-sized" pieces.

50 MB SQL File?  Are you inserting or creating a ton of data?  It would be recommended to insert or link to the other database if you are using temp tables.

SELECT TOP 1 from Table
would trim down the results.

HTH,

Kent
0
 

Author Comment

by:arthurh88
ID: 39223747
yes they are 80,000 insert statements.   i dont know what you mean by BCP it or how to load it into a text file, other than renaming it to .txt....?

it is a ZIP CODE database that i just purchased for 140 bucks.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:arthurh88
ID: 39223752
i guess i could cut and paste chunks of it at a time, but PLEASE tell me there is an easier way lol
0
 
LVL 20

Accepted Solution

by:
dsacker earned 500 total points
ID: 39223759
You can split the file into parts, perhaps each 10-15 MB in Size. If you have any CREATE TABLE or statements at the top other than INSERTs, which prep the way, leave them. Then break at 20000 inserts. Then create a 2nd file with the next 20000 inserts, and so on. Execute them one after the other.
0
 
LVL 20

Expert Comment

by:dsacker
ID: 39223769
Did you get your database (that you purchased) by chance just like that SQL, or did they also give you an Access version of it? Because if you got an Access database of it, you can export that right into SQL Server.
0
 
LVL 17

Expert Comment

by:Kent Dyer
ID: 39223784
BCP would be good..  Another way would be OSQL..  For example:

osql -SINSTANCE\SERVERS -Uuser -Ppassword -n -iyour_sql_file.sql -oresult.log -w250

Open in new window


You could do it as part of a DTSX package to import.

HTH,

Kent
0
 
LVL 20

Expert Comment

by:dsacker
ID: 39223794
If OSQL blows, try SQLCMD. Use everything kdyer showed you in his code, just substitute sqlcmd for osql.
0
 

Author Closing Comment

by:arthurh88
ID: 39224172
this is exactly what im doing, and its working...although....i dont like the manual work lol.  but yes, thank you.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

707 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