Link to home
Start Free TrialLog in
Avatar of arthurh88
arthurh88

asked on

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

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
Avatar of dsacker
dsacker
Flag of United States of America image

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?
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
Avatar of arthurh88
arthurh88

ASKER

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.
i guess i could cut and paste chunks of it at a time, but PLEASE tell me there is an easier way lol
ASKER CERTIFIED SOLUTION
Avatar of dsacker
dsacker
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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
If OSQL blows, try SQLCMD. Use everything kdyer showed you in his code, just substitute sqlcmd for osql.
this is exactly what im doing, and its working...although....i dont like the manual work lol.  but yes, thank you.