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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容