SQL Packager 8

Using the command line

Creating or upgrading a database

You use the SQL Packager command line to run a package to create a new database or upgrade an existing one.

To create or upgrade a database:

  1. Open a Command Prompt window in the folder containing the package you want to run.

    To do this, navigate to the folder, then hold Shift, right-click and select Open command window here

    Alternatively, open a Command Prompt window anywhere and change directory to the folder containing the package. For example:

    cd "C:\Documents\Packages"
  2. At the command prompt, type the name of the package. Then, specify the name of the SQL Server where you want to create or upgrade the database, and the name of the database you want to create or upgrade. For example:

    WidgetPackage.exe /server:MyServer\SQL2014 /database:WidgetSales

    If you want to use your SQL Server authentication, specify the username and password for the SQL Server using the /username and /password switches. 

    If you don't specify a username and password, Windows authentication will be used.

  3. If the package contains a script or scripts to upgrade a database, you don't need to specify any more switches.

    If the package contains a script or scripts to create a database, you need to specify one of the following switches:

    • /makedatabase 
      The database will be created using the default settings, and then the packaged script(s) will be run.
    • /createdatabasesql
      The database will be created using the specified SQL script, and then the packaged script(s) will be run.

    If you want to run a SQL script before running the package, specify /presql. If you want to run a SQL script after running the package, specify /postsql.

  4. Once you've finished specifying switches, press Enter.
    The database is created or upgraded.

Examples

In the following examples, the package WidgetSalesNew.exe contains scripts to create a new database, and the package WidgetSalesUpgrade.exe contains scripts to upgrade an existing database.

To create the database WidgetSales:

WidgetSalesNew.exe /server:MyServer\SQL2014 /database:WidgetSales /makedatabase

To create the database WidgetSales with custom settings:

WidgetSalesNew.exe /server:MyServer\SQL2014 /database:WidgetSales /createdatabasesql:"C:\Scripts\WidgetSalesCreation.sql"

To upgrade the database WidgetSales:

WidgetSalesUpgrade.exe /server:MyServer\SQL2014 /database:WidgetSales

To run the SQL script PreUpgrade.sql, then upgrade the database WidgetSales, and then run the SQL script PostUpgrade.sql:

WidgetSalesUpgrade.exe /server:MyServer\SQL2014 /database:WidgetSales /presql:"C:\Scripts\PreUpgrade.sql" /postsql:"C:\Scripts\PostUpgrade.sql"

Switches

When you run a package from the command line, you can use the following switches:

/server:<server>

The name of the SQL Server.

/database:<database>

The name of the database you want to create or upgrade.

/username:<username> (optional)

The username for the SQL Server. If you don't specify a username and password, Windows authentication will be used.

/password:<password> (optional)

The password for the SQL Server. If you don't specify a username and password, Windows authentication will be used.

/makedatabase (optional)

Creates the database on the SQL Server. The database will be created with the default settings. If you want to create a database with custom settings, you must specify /createdatabasesql instead.

/createdatabasesql:<file path> (optional)

A SQL script to create a database before running the package. This is useful, for example, if you don't want to use the default collation. The script is run before any specified /presql script. You can't specify multiple scripts.

If you're using /createdatabasesql, you must use /database to specify the name of the database that /createdatabasesql will create.

/presql:<file path> (optional)

A SQL script to run before the package is run. You can't specify multiple scripts.

/postsql:<file path> (optional)

A SQL script to run after the package has been run. You can't specify multiple scripts.

Note that there is no longer a /quiet switch, as this is now the default setting.



Didn't find what you were looking for?