Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any programs that will shrink the size of a sql script file?

Tags:

sql

sql-server

I have a SQL script which is extremely large (about 700 megabytes). I am wondering if there is a good way to reduce the size of the script?

I know there are code minimizers for JavaScript and am looking for one to use with SQL scripts.

I am not looking to get performance on the SQL script. I am trying to make the file size smaller. Removing excess whitespace. Keeping name-qualification down so that the script file sizes can be smaller.

If I attempt to load the file in SQL Server Management Studio I get this error.

Not enough storage is available to process this command. (Exception from HRESULT: 0x80070008) (mscorlib)

like image 277
Brendan Enrick Avatar asked Jan 24 '23 02:01

Brendan Enrick


1 Answers

What's in this script of 700MB?! I would hope that there are some similarities/repetitions that would allow it to shorten the file.

Just some guesses:

  • Instead of inserting a million records using Insert statements, use a bulk loading tool
  • Instead of updating a number of individual records, try to batch updates to the same value into one (e.g. Update tab set col=1 where id in (..) instead of individual updates)
  • long manipulations can be defined as a stored procedure (before running the script) and the script would only have to call the stored proc

Of course, splitting the script up into smaller portions and calling each one from a simple batch file would work too. But I'd be a little worried about performance (how long does the execution take?!) and would look for some faster ways.

like image 178
Thorsten Avatar answered Feb 01 '23 15:02

Thorsten