Readme_Execute Process Package Sample
This sample works only with SQL Server 2005 and SQL Server 2008. It will not work with any version of SQL Server earlier than SQL Server 2005.
This sample works with the SQL Server 2005 version of the AdventureWorks
OLTP database. To install this database, see
Sample Databases for Microsoft SQL Server 2008
The Execute Process sample is a package that runs an executable from within the package. In this case, the sample package includes the following Integration Services components:
- An Execute Process task that runs the Expand utility (expand.exe). The
Expand utility decompresses a CAB file that contains an Excel spreadsheet that is subsequently used as source data for the rest of the package.
- An Execute SQL task uses a stored procedure to create the ExecuteProcessDest table the first time that the package runs. (The stored procedure that creates the table is stored in a separate file.) The Execute SQL task then truncates
ExecuteProcessDest table when the package is run again.
- An OLE DB source reads the data from the Excel spreadsheet, and an OLE DB destination writes the data from the spreadsheet to
- A second Execute SQL task queries the ExecuteProcessDest table and stores the table rows in a variable of the
Object data type.
- A Foreach Loop container extracts the table row values, that stored in the variable of the
Object data type, into separate variables. The container has a Script task that writes the values of the separate variables to a text file. If you run the sample on a non-English version of Windows, you may have to substitute the localized name of the
Program Files folder to open or run the sample.
|Samples are provided for educational purposes only. They are not intended to be used in a production environment and have not been tested in a production environment. Microsoft does not provide technical support for these samples.
Running this sample package requires the following:
- The sample package and data files that it uses must be installed on the local hard disk drive.
- You must have installed and have administrative permissions on the AdventureWorks OLTP database.
- If you intend only to run the sample package from the command line, you must install Integration Services.
- If you intend to open the package in SSIS Designer and run the sample package, you must install Business Intelligence Development Studio.
- You may have to modify the Execute Process Task to provide the correct path of the
Expand utility. Depending on the operating system, the Expand utility may be located in a different directory than that specified in the sample package. To modify the Execute Process task, right-click the task in the
Control Flow tab and select Edit. In the Execute Process Task Editor, set the path of the
Executable property to the folder where the Expand utility is located. For more information about how to install samples, see the topic, "Installing Sample Integration Services Packages", in SQL Server Books Online.
Location of the Sample Package
If the samples were installed to the default installation location, the Execute Process sample package is located in the following folder:
C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\ExecuteProcess Sample\ExecuteProcess\
The following files are required to run this sample package.
||The sample package.
||The CAB file that contains the compressed Excel spreadsheet used as the data source in the package.
||The stored procedure that creates a destination table in the AdventureWorks database.
||The text file that contains the results of the query that the second Execute SQL task runs.
Running the Sample
The package can be run from the command line by using the dtexec
utility, or can be run in Business Intelligence Development Studio.
If you are using a non-English version of Windows, of if you have installed the samples to a non-default location, you may have to update the
property of any file connection managers used in the package to run the sample package successfully. You should verify that the path used in the connection manager is valid on your computer, and if you need to, modify the path so that
it uses the correct path to the sample files.
|This sample uses the Microsoft Jet 4.0 OLE DB provider, for which there is no 64-bit version. The package fails on a 64-bit computer.
For this sample, you may have to update "Program Files" in the ConnectionString
property for the Check Query Results, CreateExecute
Process_Dest.sql, and customers connection managers.
To run the package by using dtexec
- Open a Command Prompt window.
- Change the directory to C: Program Files\Microsoft SQL Server\100\DTS\Binn, the location of
- Type the following command: * dtexec /f "C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx" *
- Press Enter.For more information about how to run the package by using the
dtexec utility, see the topic, "dtexec Utility", in SQL Server Books Online.
To run the package in Business Intelligence Development Studio
- Open Business Intelligence Development Studio.
- On the File menu, point to Open, and then click Project/Solution.
- Locate the ExecuteProcess* Sample* folder, and then double-click the file named ExecuteProcess.sln.
- In Solution Explorer, right-click ExecuteProcess.dtsx in the SSIS Packages folder, and then click
Execute Package. For more information about how to run the package in Business Intelligence Development Studio, see the topic, "Running Packages", in SQL Server Books Online.
Components in Sample
The following table lists the tasks, sources, and destinations that are used in the sample.
|Execute SQL task
||Runs the stored procedure in the file, CreateExecuteProcess_Dest.sql, to create the destination table in the
AdventureWorks database. The table is created the first time that you run the package. If you run the package again, the table is truncated.For its return code, the stored procedure returns a value of 0 or 1. A value of 0 indicates that the stored procedure
ran successfully; a value of 1 indicates that the stored procedure did not run successfully. The task stores the return code in a package variable,
ReturnCode. Between the Execute SQL task and the Execute Process task is a precedence constraint. This precedence constraint allows the Execute Process task to run only if the following conditions are true:
- The Execute SQL task finishes successfully.
- The ReturnCode variable contains a value of 0. |
|Execute Process task
||Runs the Expand utility, which decompresses Customers.cab.
|Data Flow task
||Runs the data flow in the package.
|OLE DB source
||Uses the decompressed Excel spreadsheet as the data source.
|OLE DB destination
||Saves the data in the Excel spreadsheet to the destination table that was created by the Execute SQL task.
|Execute SQL task
||Queries the ExecuteProcessDest table and stores the table rows, as a
Full result set result set, in a variable of the Object data type. The name of the variable is
|Foreach Loop container
||Iterates through each table row stored in the SQLReturn variable and extracts column values into package variables that are mapped to the columns. To enumerate the table rows, the Foreach Loop container uses the Foreach ADO enumerator.
||Writes the values of the variables that are mapped to the ExecuteProcessDest columns to a text file.
|Flat File connection manager
||Connects to the file to which the Script task writes the value of the variables. The name of this Flat File connection manager is
Check Query Results.
|File connection manager
||Connects to the file that contains the stored procedure that creates the ExecuteProcessDest table. The name of this File connection manager is
|OLE DB connection managers
||Connects to the Excel spreadsheet by using the Microsoft Jet 4.0 OLE DB provider. The name of this OLE DB connection manager is
customers. Connects to the AdventureWorks database by using the SQL Server Native Client. The name of this OLE DB connection manager is
To see the execution results of the Execute Process sample package, open SQL Server Management Studio. In
, connect to the server that contains AdventureWorks
. In SQL Server Management Studio, click
and select Database Engine Query
. In the database list, which defaults to the
database, select the AdventureWorks
database, or type USE
in the query window and press F5
to change the database.
Type and run the following Transact-SQL query:
|Select * from AdventureWorks.dbo.Execute_Process_Dest
© 2008 Microsoft Corporation. All rights reserved.