Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / database / SQL-Server

Developing a SSIS Package

2.11/5 (7 votes)
2 Nov 20061 min read 1  
An article on configuring an SSIS Package.

Sample Image

Introduction

This articles describes how to configure and create expressions in SQL Server 2005 Integration Services (SSIS).

Using the code

If you want to use the package which is developed in some other machine, it fails to open because of the package encryption. Normally, a package is stored in XML format and gets encrypted depending on the setting you have configured. By default, the protection level property for that package is "EncryptSensitiveWithUserKey". In this whenever the package is saved, it encrypts all sensitive information (like passwords) using machine credentials and saves it. I prefer this property value to be DontSaveSensitive, which does not save any sensitive information.

But there is a catch here. If it is not saving any information, how do we get the required information while the user tries to run the package. For that you have to create variables and create the expressions whenever needed.

Suppose you want to export data from the source (text file) to the destination (SQL Server). You need to maintain both the source path as well as the destination connection in variables. Create variables like this:

SourceConnection..."c:\source\"
DestiUserID= "sa"
DestiPassword="sa"
DestiDataBase ="TempData"
DestDataSource= "10.12.12.123"
Assign the scope of these variables as package level.

While creating the connection manager for the source and the destination instead of using a scalar connection string, use dynamic connection strings which can evaluate the expression on the fly. Set the expression for the connection string for OLEDB as:

C#
Data Source= "+ @[User::DestDataSource] +";User ID= "+ 
             @[User::DestiUserID]   +";Password= "+ 
             @[User::DestiPassword] + 
             ";Initial Catalog= "+ @[User::DestiDataBase]  + 
             ";Provider=SQLNCLI.1;Auto Translate=False;"
Set the expression for the connection string for the source as:
@[User::SourceConnection]+"source.txt"

The expression follows the C# syntax.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here