SQL Packager 7

Examples using the command line

This topic provides some simple examples of how to use the command line interface.

You may also wish to refer to Frequently asked questions for the command line.

Packaging databases

To package database WidgetSales on the local SQL Server, creating a package executable called WidgetPackage.exe in C:\Packages, which will create a new, identical database:

sqlpackager /database1:WidgetSales /location:"C:\Packages"
     /name:WidgetPackage /makeexe

To create the same package and run it immediately (for example, if you want to test the package):

sqlpackager /database1:WidgetSales /location:"C:\Packages"
     /name:WidgetPackage /makeexe /run

To package database WidgetSales on the local SQL Server, creating a C# project called WidgetPackage in C:\Packages\Projects, which will create a new, identical database:

sqlpackager /database1:WidgetSales /location:"C:\Packages\Projects"
     /name:WidgetPackage /makeproject

To create the same package and open it immediately in Microsoft Visual Studio:

sqlpackager /database1:WidgetSales /location:"C:\Packages\Projects"
     /name:WidgetPackage /makeproject /open

To package an upgrade from WidgetDev to WidgetLive creating a package executable called WidgetPackage.exe in C:\Packages:

sqlpackager /database1:WidgetDev /database2:WidgetLive\\     /location:"C:\Packages" /name:WidgetPackage /makeexe

In this example, when the package is run, WidgetLive will be updated.

Using /presql and /postsql

Packages created by SQL Packager support the /presql and /postsql switches. These switches allow you to specify SQL scripts to run before and after the package executes.

Note that any SQL scripts specified by /postsql are always run, even if errors occur when the package executes.

For example, to run the script WidgetPostScript.sql after the package WidgetPackage.exe, enter:

widgetpackage.exe /postsql:WidgetPostScript.sql

Didn't find what you were looking for?