Sep252013

Import Large SQL Scripts into SQL Server

Today's quick tip is brought to you by the following error message:

Cannot Execute Script

I received that when trying to import a 31,000 line SQL file via SQL Server Management Studio. If you're just trying to run a single script, you can drop into a command line and use sqlcmd:

sqlcmd -S myServer\\instanceName -i C:\\myScript.sql -o C:\\EmpAdds.txt

Via Microsoft Technet: Run Transact-SQL Script Files Using sqlcmd.