How to execute a huge SQL file with Microsoft Sql Server<!-- --> | <!-- -->Patrick Desjardins Blog
Patrick Desjardins Blog
Patrick Desjardins picture from a conference

How to execute a huge SQL file with Microsoft Sql Server

Posted on: December 17, 2012

Here is a small article that could be more a note than something else. If you have a lot of SQL statement to execute, let say few gigs of statement, this won't load into SQL Server Manager. What you can do is to use the sqlcmd command. Open a DOS console and go where you have installed Sql Server Mananger. Mine is:

1c:\\Program Files (x86)\\Microsoft SQL Server\\90\\Tools\\Binn

In the console, you need to specify the server and instance you want to execute the file to. Optionnaly, you can write the output to a file.

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

That's it. Nothing more complicated.