Welcome to my blog!

How to run big sql script file

October 20, 2019 23:31

How to run big sql script file (edit)


Here's project that enables any developers or others to run the big sql script file greater than 300MB or any size. It also supports rollback feature & others.

Folder: ..\BigSqlRunner\sourceCode\bigsqlrunner\release\


To run these scripts use:

  1. The osql command line utility that comes with SQL Server:
    osql -H <computer_name> -S <instance_name> -U <username> -P <password> -i <path>
  2. The sqlcmd command line utility that comes with SQL Server:
    sqlcmd -S <computer_name\instance_name> -d <database_name> -i <path> -o <output>
  3. ApexSQL Run Script:
    1. Download ApexSQL Run Script
    2. Unzip it into a folder
    3. Use the Command line and navigate to the folder where the file was unzipped
    4. Run the utility with the following parameters:
      ApexSqlRunScript <computer_name\instance_name> <database> <path>


SELECT name, physical_name AS current_file_location
FROM sys.master_files


C:\Program Files\Microsoft SQL Server\xxx\Tools\Binn\SQLCMD.EXE

C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\xxx\Tools\Binn\SQLCMD.EXE

sqlcmd -S [MSSQLSERVER] -U sa -P 123456 -d [DemoDB] -i "DemoDB_Script.sql"

C:\Program Files\Microsoft SQL Server\xxx\Tools\Binn\bcp.exe

C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\xxx\Tools\Binn\bcp.exe


Recent posts