Running SQL scripts that are too large to be loaded into SQL Server Management Studio

Posted: (EET/GMT+2)

 

When working with larger databases, you might run into a situation where you cannot load an SQL script file (.sql file extension) to the SQL Server Management Studio (SSMS). If you try to load a file that is too large, you will get the "Out of Memory" error while opening your script file.

Since SQL Server Management Studio is a 32-bit application, it has a hard limit of 2 GB of RAM (by default). This means that scripts files above the size of roughly 1.5 GB are too large.

But what to do if you have, say, a 4 GB script file which you need to run? Try SQLCMD instead. SQLCMD is a command-line tool from running commands and scripts, and it can work with large files, too.

With the help from the "-i" switch, you can run an external script file.

Out of memory error solved.