Sometime script.sql is too large(>150MB) to unable to be executed within SSMS
, and when we get such error message:
insufficient memory to continue the execution of the program.(mscorlib)
we can use SQLCMD
instead.
Steps:
- Press
Win+R
to opencmd
. - Execute
cd C:\Program Files\Microsoft SQL Server\110\Tools\Binn
to go to the SQL installation location. - Execute the following code to execute the script.
sqlcmd -i "C:\script.sql" -s "LAPTOP-BNFDDN18\LIN SIYIN"
// i: Specify the file path(file location and file name) of the input script.
// s: Specifies the instance of SQL Server(user name) to which to connect.
- If you want to save the output into a new file, execute:
sqlcmd -i "C:\script.sql" -s "LAPTOP-BNFDDN18\LIN SIYIN" -o "D:\results.txt"
- Note: Reference
网友评论