SQL Server: Run a Large Script File Against a Database and Import Data

12/18/2014 9:38:18 PM

SQL Management Studio has a limit on the size of a script file that it can open. To run a large sql file to import data against a SQL Server Db, you can use the following command. This needs to be run in a Windows Command Prompt.

Full list of command line options: http://msdn.microsoft.com/en-us/library/ms162773.aspx

--trusted connection, probably local db
>sqlcmd -S Server\SQLEXPRESS2012 -d DestinationDb -i "C:\Users\Me\Desktop\large_sql_script.sql"


--with a username password
>sqlcmd -S Server\SQLEXPRESS2012 -d DestinationDb -i "C:\Users\Me\Desktop\large_sql_script.sql" -U sa -P saPassword