How to execute large SQL scripts

Applies to
ApexSQL Data Diff, ApexSQL Diff, ApexSQL Log, ApexSQL Recover

Summary
This article shows how to execute large scripts created by ApexSQL tools which are too big to be opened or executed by SQL Server Management Studio Query Editor

Description
Synchronization scripts, undo and redo scripts, and recovery scripts generated by ApexSQL tools can be so big that SQL Server Management Studio Query Editor can’t open and execute them

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>

Last updated
October 08, 2014