Embracing the Messiness in Search of Epic Solutions

MS SQL Server: Executing SQL Script from Command Line

Posted

in

PROBLEM

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

SOLUTION

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

Comments

Leave a Reply