How to executed script.sql in SQLCMD

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:
  1. Press Win+R to open cmd.
  2. Execute cd C:\Program Files\Microsoft SQL Server\110\Tools\Binn to go to the SQL installation location.
  3. 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.
  1. 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"
  1. Note: Reference

你可能感兴趣的:(How to executed script.sql in SQLCMD)