MS SQL Server: Executing SQL Script from Command Line


When opening a 150MB SQL script file in Microsoft SQL Server Management Studio, the following error appears:-


Instead of opening the large SQL script file and execute it, we can execute it directly from command line.

sqlcmd -E -d[database_name] -i[sql_file_path]

… where -E uses trusted connection, -d points to the database and -i points to the SQL script file path.

For example,

sqlcmd -E -dshittydb -ic:\Users\shittyuser\shittydb.sql

Leave a Reply

Your email address will not be published. Required fields are marked *