dtutil /FILE "C:\SSIS\Packages\Mailing Opportunities.dtsx" /COPY SQL;"Mailing Opportunities" /DestS W8KR2 If you still have the Mailing Opportunities package saved to the MSDB database
Trang 1In this example, we used a UNC path to specify the location of the package AIT
is the name of the second server I’m using to test Integration Services packages designed for this book
4 Verify that the Mailing Opportunities package exists in the My SSIS Packages store:
dtutil /EXISTS /DTS "\My SSIS Packages\Mailing Opportunities"
The DTS option specifies that the verification for existence of the package should be done on the SSIS Package Store Note that the DTS option cannot be specified with the FILE, SQL, Server, User, or Password options
Exercise (Copy SSIS Packages)
If you have used the COPY command of good old DOS (this is still available at the command prompt, but hardly anyone uses it now), you will find copying packages quite the same Using the DOS COPY command, you provide the source path and name of the file to be copied and destination path and name of the file to be copied to With dtutil, you provide similar parameters but in a slightly more complex manner because multiple storage locations (SQL, DTS, and FILE) are involved here The syntax for the COPY command is shown here:
dtutil /{SourceLocation} [SourcePathandPackageName] /COPY {DestinationLocation};[DestinationPathandPackageName]
Note that you do not use a backslash (/) when you provide the destination location after the COPY command
5 You have saved your package in the file system while designing the package using BIDS Now you want to copy your package from the file system to the MSDB database of the SQL Server (named W8KR2 in my case)
dtutil /FILE "C:\SSIS\Packages\Mailing Opportunities.dtsx" /COPY SQL;"Mailing Opportunities" /DestS W8KR2
If you still have the Mailing Opportunities package saved to the MSDB database of your server, you will see a confirmation prompt, “Package ‘Mailing Opportunities’
already exists Are you sure you want to overwrite it?” Typing Y will overwrite the package and typing N will cancel the command To stop such confirmation
prompts, you can use the /Quiet option in the command while trying to copy, move, or sign the package The option DestS specifies the destination SQL Server
If this option is missing in the dtutil command, the local SQL Server will be used
Opportunities01 When you see the message “The operation completed
successfully,” switch to SQL Server Management Studio; refresh the MSDB folder under Stored Packages in Integration Services to see this new package there
Trang 26 You have a package in the MSDB database and want to copy it to the file system
on a different server:
dtutil /SQL "Mailing Opportunities" /SourceS W8KR2 /COPY
FILE;"\\AIT\Data\Mailing Opportunities.dtsx"
By now, you must have noted that the double quotation marks have been used
on the package path and name This is because the package has a white space in
its name; you don’t need to use double quotes if your package doesn’t have white
space in its path or name The SourceS option specifies the source SQL Server
name Again to clarify, W8KR2 and AIT are the names of servers I use in my little
test lab You should replace the names with your computer names to perform this
test Once the command has been run successfully, check the destination location
to see that the package has been copied over
Exercise (Move SSIS Packages)
The MOVE option moves an SSIS package from one storage location to another The
syntax for this option is quite similar to the syntax of the COPY option
dtutil /{SourceLocation} [SourcePathandPackageName] /MOVE
{DestinationLocation};[DestinationPathandPackageName]
7 You have a package in your My SSIS Packages store, which you want to archive—
i.e., you want to remove it from the SSIS Package Store and move it to the central
archival location
dtutil /DTS "\My SSIS Packages\Mailing Opportunities" /MOVE
FILE;"\\AIT\Data\Mailing Opportunities.dtsx"
You will see a prompt to confirm that you want to write the existing package
Type Y to overwrite Once the package is moved successfully, switch over to SQL
Server Management Studio and refresh the My SSIS Packages folder to see that
the package has been removed from there Check the destination folder to find
the package exists there
8 Another example of moving a package could be from the default SQL Server
instance to the named SQL Server instance The TRAINING is the named
instance that has been used with user name and password in the following
command:
dtutil /SQL "Mailing Opportunities" /MOVE SQL;"Mailing
Opportunities"
/DestU admin /DestP Tra1n1n9 /DestS SARTH\TRAINING
Trang 3Exercise (Delete SSIS Packages)
You can delete a package using the delete (DEL) option The generic syntax for using the option is shown here:
dtutil /DEL /{SQL | DTS} [DestinationPathandPackageName]
9 You want to delete an existing package from a shared folder on the network:
dtutil /DEL /FILE "\\AIT\Data\Mailing Opportunities.dtsx"
When you see the message “The operation completed successfully,” switch over
to Windows Explorer and check that the package has been deleted from the specified folder
10. You want to delete a package from the MSDB database in SQL Server:
dtutil /DEL /SQL "Mailing Opportunities01"
On successful deletion, switch over to SQL Server Management Studio and go to the MSDB folder; then refresh it to find that the package is no longer there This option uses Windows Authentication, which is more secure It is recommended that you use Windows Authentication whenever possible, though you can also use SQL logins to operate dtutil by specifying an SQL user name and password for the SQL Server
Exercise (Sign SSIS Packages)
When you are working on developing a complex SSIS project consisting of several packages, you may want to deploy the packages when they have achieved a certain level
of functionality, while the development team continues to further enhance the package functionalities In such scenarios, if you are concerned that your packages can be changed and run accidentally by other developers working on the same project, you can use the SIGN option to sign the packages and prevent these changed packages from being loading and running
dtutil /{SourceLocation} [SourcePathandPackageName] /Si[gn]
{DestinationLocation};[DestinationPathandPackageName];Hash
The SIGN option uses three arguments separated by semicolons An SQL destination can include the DESTU, DESTP, and DESTS options The Path argument specifies the location of the package on which to take action and the Hash argument specifies a certificate identifier expressed as a hexadecimal string of varying length
11. For protecting your package saved in the file system, use the following command:
dtutil /FILE "C:\SSIS\Packages\mailing Opportunities.dtsx" /SIGN FILE;C:\SSIS\Packages\SignedPackage.dtsx;
7B18F301A198B83778B5E546729B0539A0D4E758
Trang 4The hash value actually corresponds to the digital certificate I’ve installed on my
computer, which you should change accordingly when you use this command
Exercise (Encrypt SSIS Packages)
Properties containing information such as a password or connection string can be
treated as a sensitive data Properties containing sensitive data can be protected using
encryption Integration Services packages have a property called ProtectionLevel that
you can use to set the level of protection for your packages If you are creating a custom
task, you can specify that the properties be treated as sensitive Following are the
ProtectionLevel options available:
Level 0 strips the sensitive information
c
Level 1 encrypts sensitive data using the local user credentials
c
Level 2 encrypts sensitive data using the required password
c
Level 3 encrypts the package using the required password
c
Level 4 encrypts the package using the local user credentials
c
Level 5 encrypts the package using SQL Server storage encryption
c
The generic syntax for encryption option is shown here:
dtutil /{SourceLocation} [SourcePathandPackageName] /En[crypt]
{DestinationLocation};[DestinationPathandPackageName];ProtectionLevel;Password
12. Let’s encrypt a package stored in the file system with a password using this
command:
dtutil /FILE "C:\SSIS\packages\mailing opportunities.dtsx" /ENCRYPT File;
"C:\ssis\packages\Encrypted mailing opportunities.dtsx";3;abcd
Now, if you open this newly created package Encrypted mailing opportunities.dtsx
after adding it to a project in BIDS, you will have to specify the encryption
password abcd while adding and loading the package You may be wondering by
now how one can decrypt the encrypted packages Yes, you are right; dtutil has a
Decrypt option too Using this option lets you set the decryption password when
loading a package with password encryption
Trang 5Exercise (List Contents of Folders)
You may want to check the contents of folders and subfolders in My SSIS Packages store and SQL Server (MSDB database) storage area FDi is a short form of asking dtutil to show a folder directory:
dtutil /FDi {SQL | DTS}; FolderPath [;S]
You can use the S argument with this command if you want to see the contents of subfolders
13. Here’s how you check the contents in SSIS Packages Store area:
dtutil /FDi DTS
When you use this command, the contents of the root folder will be returned, showing you the File System, MSDB, and My SSIS Packages folders
14. To see the contents of My SSIS Packages folder, type this:
dtutil /FDi DTS;"My SSIS Packages"
Exercise (Create a Folder)
You can also create subfolders in the Integration Services storage area or the MSDB database for storing packages in a hierarchical manner
dtutil /FC[reate] {SQL | DTS};ParentFolderPath;NewFolderName
where ParentFolderPath is the location for the new folder and NewFolderName is the
name of the new folder
15. Create a folder in the MSDB database:
dtutil /FC SQL;\;MyPackages
When you see the message “The operation completed successfully,” run the following command:
dtutil /FDi SQL
You will see the MyPackages folder created in the MSDB database You can also verify the existence of a folder as we did for packages To verify the MyPackages folder, type this:
dtutil /FE SQL;MyPackages
Trang 6Exercise (Rename a Folder)
The folders created in the Integration Services area and the MSDB database can be
renamed using the FR option in dtutil
dtutil /FR[ename] {SQL | DTS};ParentFolderPath;OldFolderName;NewFolderName
where ParentFolderPath is the location of the folder to rename, OldFolderName is the
current name of the folder, and the NewFolderName is the new name of the folder.
16. Rename the MyPackages folder
dtutil /FR SQL;\;MyPackages;Archives
Exercise (Delete a Folder)
Using the FDe command option, you can delete a folder existing in Integration
Services, the storage area, or the MSDB database of the SQL Server
dtutil /FDe[lete] {SQL | DTS};ParentFolderPath;FolderName
where ParentFolderPath is the location of the folder to delete and FolderName is the
name of the folder to delete
17. Delete the Archives folder from the MSDB database:
dtutil /FDe SQL;\;Archives
to verify the deletion of the folder from the MSDB folder under the Stored
Packages folder
18. While working on big projects, you will create a package with some basic
configurations, connection managers, auditing tasks, variables, and such configured
in it You will then use this package as a template package whenever you’re starting
to develop a new package This approach will save lot of time and will apply the
same development standards across all the packages However, this approach
requires you to recreate the package ID All the packages get a GUID created
automatically at the time of package creation that you can also change any time
and create a new ID This ID is important, as many applications and utilities use
them to identify and run packages If two packages have same ID, obviously, the
applications or utilities will get confused and undesirable results may occur You
can generate a new ID at any time during design time by going to the ID property
and selecting the <Generate New ID> option You can also generate a new ID
even after the package has been saved and avoid reopening a package; actually
you can generate IDs for multiple packages in a folder when you use the dtutil
Trang 7command in a batch Use the following command to generate a new GUID, and verify it by opening the package in BIDS before and after the command
dtutil /I /FILE "C:\SSIS\Packages\mailing Opportunities.dtsx"
Review
In this exercise, you learned how to use the dtutil utility to manage your packages and the storage areas You used it to copy, move, delete, sign, and encrypt packages stored
in various storage areas You also used the dtutil utility to see the contents of folders;
to create, rename, and delete a folder from various storage areas; and to verify the existence of a folder or a package in a particular storage area
Running SSIS Packages
You can run an Integration Services package using the following applications or utilities: SQL Server Import and Export Wizard
c BIDS c
Execute Package Utility (DTExecUI) c
DTExec Utility c
SQL Server Agent c
Programmatically c
Your choice of tool or utility can be guided by various factors as discussed next
SQL Server Import and Export Wizard
The SQL Server Import and Export Wizard is the easiest utility to work with Its interactive GUI provides a simple interface to build and run Integration Services packages You have already used this tool in variety of scenarios to create and run packages For more details on the SQL Server Import and Export Wizard, refer to Chapter 2
BIDS
You can run your packages from within BIDS while you are developing, debugging, and testing your packages You can run your package by clicking the Start Debugging button on the toolbar, by pressing f5, or by right-clicking the package in Solution Explorer and choosing the Execute Package option from the context menu You have
Trang 8already used these options while developing packages in the last chapter BIDS uses
an execution host DtsDebugHost that will start whenever you run a package inside
BIDS You can see this process in the Task Manager while running a package The
DtsDebugHost.exe file exists in the Binn folder under DTS and has both 32-bit and
64-bit versions This is the main reason BIDS can support both 32-bit and 64-bit
execution environments despite being itself a 32-bit application You can control the
execution environment by using the Run64BitRuntime debugging configuration in
Project properties The Run64BitRuntime is by default set to True, which means the
package will execute using the 64-bit version of DtsDebugHost if the 64-bit SSIS run
time is installed; otherwise, this setting is ignored BIDS attaches to this process at run
time to report back the debugging information This reporting is additional overhead
on execution, and hence using BIDS is the slowest method to run a package Refer
to Allan Mitchell’s blog for “Comparing Overhead on the Execution Methods” on
SQLIS.com to compare performances of different methods
Also, when you run a package in BIDS, a Progress tab appears to show how the
package is doing while the package is running, which finally converts into an Execution
Results tab when you switch to design mode or stop debugging on package completion
You do not need Integration Services to design and run packages inside BIDS; however,
the packages run in this fashion in SSIS Designer run immediately and cannot be
scheduled If you want to run your package outside BIDS, you must have Integration
Services installed on the local computer If your solution contains multiple projects and
packages and you want to run a particular package before any other package each time
you execute the project, you will have to mark that package as a startup package To
mark a package as a startup package, right-click the project in the Solution Explorer
window and choose Properties Go to the Debugging page and select the package name
in the StartObjectID field in the Start Action section
Execute Package Utility (DTExecUI)
The Execute Package Utility (DTExecUI) is a GUI-based version of the DTExec
command prompt utility covered in the following section To run a package using
DTExecUI, connect to Integration Services in SQL Server Management Studio,
right-click the package, and select the Run Package option from the context menu or simply
double-click the package file to invoke the DTExecUI Alternatively, you can first
invoke the utility by choosing Start | Run | DTExecUI and then select the package to
run from the File System, MSDB, or SSIS Package Store root folder of the Integration
Services storage area
Trang 9Hands-On: Running an SSIS Package Using the Execute Package Utility
In this exercise, you will learn how to use the Package Execution utility to run SSIS packages
Method
You can start this utility from inside SQL Server Management Studio or from the
command prompt by typing DTExecUI
Exercise (Working with the Execute Package Utility)
In this exercise, you will use SQL Server Management Studio to start this utility and run the Mailing Opportunities package
1 While connected to Integration Services in SQL Server Management Studio, expand the MSDB folder below the Stored Packages area
2 Right-click the Mailing Opportunities package, and choose Run Package The Execute Package Utility dialog box shown in Figure 6-3 will appear
You can run your package by clicking the Execute button without any additional run-time options However, you may want to go through some of the useful configurations while deciding how to run your package
3 Click Configurations on the left pane to see the configuration files options The Package Execution utility can read the configuration files to modify the properties
of your package at run-time You can specify the order in which these files are
to be loaded This is important, as the configurations load in order starting from the top of the list, and if multiple configurations modify the same property, the configuration that loads last prevails
4 Similar to configuration files, the Package Execution utility can read the command files to include execution command lines to your package at run time Click Command Files to see the interface You can specify the order of your command files using the arrow buttons provided on the right side of this window
5 Go to the Connection Managers page You can edit the connection string of the connection manager that the package uses by selecting the check box provided in front of the connection manager This option can be very helpful if you want to test your package against different data sources or so
6 Open the Execution Options page You can configure the run-time properties such as validation behavior and maximum number of concurrent executables, and specify checkpoints for the package here
Trang 10Select Fail the package on validation warnings if you want your package to fail in
case a validation warning occurs, and specify that the package be validated only by
selecting the Validate Package Without Executing Option
means that the maximum number of concurrently running executables allowed
is equal to the total number of processors on the machine executing the package,
plus two Alternatively, you can specify the maximum number of concurrent
executables The valid values are positive numbers starting from 1 Specifying a 0
or any other negative value for this property will fail the package
Checking the Enable Package Checkpoints option lets you specify a checkpoint
file if you want to use one and also lets you override restart options already
specified in the package with those specified here
Figure 6-3 Running the Execute Package utility