Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Page 1
SSISSSIS stands for SQL Server Integration Services. It is a platform for Data integration and
Work flow applications. It can perform operations like Data Migration and ETL (Extract,
Transform and Load).
E Merging of data from heterogeneous data stores (i.e. it may be a text file, spreadsheets,
mainframes, Oracle, etc.).This process is known as EXTRACTION.
T Refreshing data in the data warehouses and data marts. Also used to cleanse data before
loading to remove errors. This process is known as TRANSFORMATION.
L- High-speed load of data into Online Transaction Processing (OLTP) and Online Analytical
Processing (OLAP) databases. This process is known as LOADING.
Tools used for the development of SSIS projects are SSDT (SQL Server Data Tool) (In SSIS2008 SQL Server Data Tool).
SSMS (SQL Server Management Studio).
Note: - Prior to SSIS, the same task was performed with DTS (Data Transformation Services)
in SQL Server 2000 but with fewer features. Difference between DTS and SSIS is as follows:DTS:Limited error Handling.
Message Boxes in ActiveX Scripts.
Page 2
Page 3
Page 4
Page 5
Page 6
Tasks
A unit of work a work flow. Tasks do the work in packages. Integration Services includes
tasks for performing a variety of functions.
The Data Flow task: It defines and runs data flows that extract data, apply transformations,
and load data.
Data preparation tasks: It copies files and directories, downloads files and data, saves data
returned by Web methods, or works with XML documents.
Workflow tasks: It communicates with other processes to run packages or programs, sends
and receives messages between packages, sends e-mail messages, reads Windows
Management Instrumentation (WMI) data, or watch for WMI events.
SQL Server tasks: It accesses, copy, insert, delete, or modify SQL Server objects and data.
Analysis Services tasks: It creates, modifies, deletes, or processes Analysis Services objects.
Scripting tasks: It extends package functionality through custom scripts.
Maintenance tasks: It performs administrative functions, such as backing up and shrinking
SQL Server databases, rebuilding and reorganizing indexes, and running SQL Server Agent
jobs.
Data Flow
Its processing responsibilities by employing the pipeline paradigm, carrying data record by
record from its source to a destination and modifying it in transit by applying
transformations. (There are exceptions to this rule, since some of them, such as Sort or
Aggregate require the ability to view the entire data set before handing it over to their
Page 7
Page 8
Other Sources
Different items which can communicate in various types of source data are listed below:
DataReader Source: The DataReader source uses an ADO.NET connection manager to
read data from a DataReader and channel it into the Data Flow.
Excel Source: The Excel source connects to an Excel file and, selecting content based on a
number of configurable settings, supplies the Data Flow with data. The Excel Source uses
the Excel connection manager to connect to the Excel file.
Flat File source: Formats of which include CSV and fixed-width columnsare still popular.
For many reasons, individual circumstances can dictate the use of CSV files over other
formats, which is why the Flat File Source remains a popular Data Flow data source.
OLE DB Source: The OLEDB Source is used when the data access is performed via an OLE
DB provider. Its a fairly simple data source type, and everyone is familiar with OLE DB
connections.
Raw file Source: The Raw File Source is used to import data that is stored in the SQL Server
raw file format. It is a rapid way to import data that has perhaps been output by a previous
package in the raw format.
XML Source: The XML Source requires an XML Schema Definition (XSD) file, which is really
the most important part of the component because it describes how SSIS should handle the
XML document.
Common and Other Transformations
Items in this category are used to perform different operations to make data in required
format.
Aggregate: The Aggregate transformation component essentially encapsulates number of
aggregate functions as part of the Data Flow, like Count, Count distinct, Sum, Average,
Minimum, Maximum, Group By with respect to one or more columns.
Page 9
Page 10
Page 11
Page 12
2. You will get new project dialog box where you should:
I.
II.
III.
IV.
V.
Page 13
Click Ok.
Below is example of an empty package. I have highlighted the elements we will use and
briefly discuss it below (you can ignore the rest):
Page 14
Page 15
6. Exeucte Package (F5) Solution Explorer Select a Package Right click Execute
Package.
7. Go to SSMS Run Select * from HumanResources.EmployeeSource query, 0 rows would
be affected, as its cleaned up.
Execute Package Task:
Execute package task is used to execute a package in another package (the way we call and
execute a function with-in another function in general C/C++ programming language).
In above created Project, Create a New SSIS Package (Project Menu Select New SSIS
Package) and rename it as Master.dtsx
Page 16
Project Reference
External Reference
Page 17
Execute Package.
---------------------------------------------------------------------------------------------------------------------------Data Conversion Transformation: Data conversion transformation is used to converts
columns to different data-type (type cast) and also add a new column/output alias for every
input column,
Note: Data conversion transformation is used to make sure both Source table structure and
destination structure are same/sync in terms of data type and length of columns.
In above created Project, Create a New SSIS Package (Project Menu Select New SSIS
Package) and rename it as DataConversion.dtsx
1. In Control Flow tab: Drag and drop a Data Flow Task and rename it as DFT Data
Conversion.
2. Double Click on Data Flow Task or Right Click on Data Flow Task and Select Edit to
navigate to Control Flow tab.
3. In Data Flow Tab, from Data Flow Source section (in Toolbox, shortcut key is Alt+Ctrl+x),
drag and drop OLEDB Source adapter/component and set the following setting to configure
OLEDB Source.
Note: OLEDB Source component is used to extract the data from any relational database
using OLEDB provider.
OLEDB Connection Manager, click New (to create a new connection as this package a
new)
Page 18
SQL Comment: Provide the following query to extract/read the data from specified
SELECT * FROM HumanResources.Employee WITH (NOLOCK) and click Build
Query to provide all the columns instead of using * (select *, kills performance of data
extract process)
Page 19
Click Ok.
4. Drag and drop OLEDB Destination, and set the following properties to configure it,
Select OLEDB Source which we configure above, we can see two arrow marks, Green and
Red
arrows marks,
Select green arrow mark (data flow pipeline) and drag and drop to OLEDB Destination,
OLEDB Connection Manager Select Connection Manager
Data access mode Table or View fast load (default option)
Name of the table or view Select a destination table if it exists, else Click New to
create a new table,
In Create Table editor, Rename OLEDB Destination (default table name) as
[DataConversion]
In the create table structure, change the datatype for the following columns to
replicate/reproduce the data conversion issue,
[NationalIDNumber] varchar(15)
[LoginID] varchar(256)
[MaritalStatus] varchar(256)
Note: Now, data types of the above columns are not matching with source columns, which
cause an issue/error.
Click Ok (Now, you can observe that, [DataConversion] table is created at specified
database).
Select Mappings Page
Click Ok.
Page 20
Select Green Arrow Mark (Data Flow pipe line) and remove/delete between Source
and destination.
Drop and drop Data Conversion Transformation (from Data Flow Transformations)
between OLEDB Source and OLEDB Destination.
Select OLEDB Source, drag and drop green data flow pipe line to Data conversion
transformation,
Double click on Data Conversion transformation and set the following properties,
Select NationalIDNumber from Available Input Columns
Input Column (NationalIDNumber) is fixed, which never changes
For every input column, SSIS creates a new Output alias which would be carry
forwarded to next level for further process,
Change the data type from DT_WSTR (nvarchar) to DT_STR (varchar)
Input Column: NationalIDNumber
Output alias: NationalIDNumberDC (renamed) and Click Ok
Page 21
Page 22
Page 23
Page 24
Select Green Arrow Mark (Data Flow pipe line) and remove/delete between Source
and destination.
Drop and drop Derived Column Transformation (from Data Flow Transformations)
between OLEDB Source and OLEDB Destination.
Page 25
Page 26
Page 27
Click Ok.
4. Drag and drop Conditional Split transformation (from Data Flow Transformations section)
after
OLEDB Source and set the following properties,
Select OLEDB Source, drag and drop green data flow pipe line to Conditional Split
transformation,
Double click on Conditional Split transformation and set the following properties,
Output Name: Single Male (rename the Case1)
Condition: [Gender] == "M" && [MaritalStatus] == "S"
Output Name: Single Female (rename the Case1)
Condition: [Gender] == "F" && [MaritalStatus] == "S"
Default Output Name : Other than Single Male and Single Female (Married
Employees)
Page 28
Click Ok
5. Drag and drop OLEDB Destination, and set the following properties to configure it,
Select OLEDB Source which we configure above, we can see two arrow marks, Green and
Red
arrows marks,
Select green arrow mark (data flow pipeline) and drag and drop to OLEDB Destination1,
and
Select Single Male Output option and click Ok.
OLEDB Connection Manager Select Connection Manager
Data access mode Table or View fast load (default option)
Name of the table or view Select a destination table if it exists, else Click New to
create a new table,
In Create Table editor, Rename OLEDB Destination (default table name) as
[SingleMaleData]
Page 29
Click Ok (Now, you can observe that, [SingleMaleData] table is created at specified
database).
Select Mappings Page
Click Ok.
6. Drag and drop OLEDB Destination2, and set the following properties to configure it,
Select OLEDB Source which we configure above, we can see two arrow marks, Green and
Red
arrows marks,
Select green arrow mark (data flow pipeline) and drag and drop to OLEDB Destination2,
and
Select Single Female Output option and click Ok.
OLEDB Connection Manager: Select Connection Manager
Data access mode: Table or View fast load (default option)
Name of the table or view Select a destination table if it exists, else Click New to
create a new table,
In Create Table editor, Rename OLEDB Destination (default table name) as
[SingleMaleData]
Click Ok (Now, you can observe that, [SingleFemaleData] table is created at specified
database).
Select Mappings Page
Click Ok.
Note: Follow the above mentioned steps to capture Conditional Split Default Output.
Merge Transformation: Merges/integrates data from two sorted data sources into
single destination.
Steps to configure Merge Transformation:
Scenario: Merges/integrates data from two sorted data sources into single destination.
In above created Project, Create a New SSIS Package (Project Menu Select New SSIS
Package) and rename it as MergeEmployee_EmpAddress.dtsx
1. In Control Flow tab: Drag and drop a Data Flow Task and rename it as DFT Data
Conversion.
2. Double Click on Data Flow Task or Right Click on Data Flow Task and Select Edit to
navigate to Control Flow tab.
3. In Data Flow Tab, from Data Flow Source section (in Toolbox, shortcut key is Alt+Ctrl+x),
drag and drop OLEDB Source adapter/component and rename it OLEDBSrc1. And set the
following setting to configure OLEDB Source.
Note: OLEDB Source component is used to extract the data from any relational database
using OLEDB provider.
OLEDB Connection Manager, click New (to create a new connection as this package a
new)
Click New In Connection Manager Editor,
Server Name: Localhost/Servername/.
Database: Select Adventure Works database from drop down.
Click Ok twice.
Page 30
SQL Comment: Provide the following query to extract/read the data from specified
SELECT * FROM HumanResources.Employee WITH (NOLOCK) and click Build
Query to provide all the columns instead of using * (select *, kills performance of data
extract process)
Page 31
Click Ok.
4. In Data Flow Tab, from Data Flow Source section (in Toolbox, shortcut key is Alt+Ctrl+x),
drag and drop OLEDB Source adapter/component and rename it OLEDBSrc2. And set the
following setting to configure OLEDB Source.
Note: OLEDB Source component is used to extract the data from any relational database
using OLEDB provider.
OLEDB Connection Manager, click New (to create a new connection as this package a
new)
Click New In Connection Manager Editor,
Server Name: Localhost/Servername/.
Database: Select Adventure Works database from drop down.
Click Ok twice.
Page 32
Page 33
5. Click Ok.
At this point if you try to edit the MERGE transformation you will get the below error. The
reason for this is because the data needs to be sorted for the MERGE transformation to
work. We will look at two options for handling this sorting need.
Page 34
7. Drag and drop Merge transformation and make a connection between OLEDBSrc1 to
Merge transformation, you will be able to see the below mentioned window and select the
input process as shown below,
Page 35
8. Click Ok
9. Drag and drop Merge transformation and make a connection between OLEDBSrc2 to
Merge transformation.
10. Drag and drop OLEDB Destination, and set the following properties to configure it,
Select OLEDB Source which we configure above, we can see two arrow marks, Green and
Red
arrows marks,
Select green arrow mark (data flow pipeline) and drag and drop to OLEDB Destination,
and set
the following properties,
OLEDB Connection Manager: Select Connection Manager
Data access mode: Table or View fast load (default option)
Name of the table or view Select a destination table if it exists, else Click New to
create a new table,
In Create Table editor, Rename OLEDB Destination (default table name) as
[MergedData]
Click Ok (Now, you can observe that, [MergedData] table is created at specified
database).
Select Mappings Page
Click Ok.
11. Execute Package
Merge Join Transformation: Merge Join Transformation merges data from 2 sorted
datasets into single destination using Joins (Inner, Left Outer and full outer Join, in SSIS
merge Join transformation does not support Right Outer Join).
Page 36
Page 37
Click Ok.
4. In Data Flow Tab, from Data Flow Source section (in Toolbox, shortcut key is Alt+Ctrl+x),
drag and drop OLEDB Source adapter/component and rename it OLEDBSrc2. And set the
following setting to configure OLEDB Source.
Note: OLEDB Source component is used to extract the data from any relational database
using OLEDB provider.
OLEDB Connection Manager, click New (to create a new connection as this package a
new)
Click New In Connection Manager Editor,
Server Name: Localhost/Servername/.
Database: Select Adventure Works database from drop down.
Click Ok twice.
Page 38
Build Query to provide all the columns instead of using * (select *, degrades
performance of data extracts process)
Page 39
5. Click Ok.
At this point if you try to edit the MERGE transformation you will get the below error. The
reason for this is because the data needs to be sorted for the MERGE transformation to
work. We will look at two options for handling this sorting need.
Page 40
7. Drag and drop Merge transformation and make a connection between LeftSource to
Merge transformation, you will be able to see the below mentioned window and select the
input process as shown below,
Page 41
8. Click Ok
9. Drag and drop Merge Join transformation and make a connection between RightSource
to Merge Join transformation.
10. Double click on Merge Join transformation, set the following properties,
in
Join Type: Inner (By default) (select the corresponding join types as discussed
Page 42
Variables: SSIS supports variables to store values based on the data types, same as
programming language,
Types of Variables:
System Defined Variables
User Defined Variable
How to use Variables in SSIS:
System Defined Variable: System defined variables can be used in any
expressions/tasks/containers/data flow components as mentioned below,
@[System::VariableName] Or @VariableName
User Defined Variable: User defined variables can be used in any
expressions/tasks/containers/data flow components as mentioned below,
@[User::VariableName] Or @VariableName
Example Package on Variables and Precedence Constraints:
In above created Project, Create a New SSIS Package (Project Menu Select New SSIS
Package) and rename it as RowCountwithVariables_PrecedenceConst.dtsx
1. In Control Flow tab: Drag and drop a Data Flow Task and rename it as DFT Data
Conversion.
2. Double Click on Data Flow Task or Right Click on Data Flow Task and Select Edit to
navigate to Control Flow tab.
3. In Data Flow Tab, from Data Flow Source section (in Toolbox, shortcut key is Alt+Ctrl+x),
drag and drop OLEDB Source adapter/component and rename it OLEDBSrc1. And set the
following setting to configure OLEDB Source.
Note: OLEDB Source component is used to extract the data from any relational database
using OLEDB provider.
OLEDB Connection Manager, click New (to create a new connection as this package a
new)
Click New In Connection Manager Editor,
Server Name: Localhost/Servername/.
Database: Select Adventure Works database from drop down.
Click Ok twice.
Page 43
Page 44
Scope
Package
DataType
Int32
Value
0
5. Use RowCount Transformation to capture number of rows which are coming from
source table/system and hold the rows count in a variable (uvSrcCount ) of type int.
Page 45
Page 46
Page 47
4. Click Ok.
5. Go to Control Flow tab and select package.
6. Select SSIS Menu Variables
7. In Variables Editor, Click Add Variable and set the following properties,
Name
uvSrcCount
uvDst1Count
uvDst2Count
uvSolutionNam
e
uvTableNames
Scope
Package
Package
Package
Package
Data Type
Int32
Int32
Int32
String
Value
0
0
0
SSIS_Morning730AMIST
Package
String
HumanResources.Employees,
dbo.DestinationTbl1, dbo.DestinationTbl2
8. In Data Flow, drag and drop RowCount transformation and make connection between
OLEDBSrc and RowCount, and also set the following properties to configure RowCount
transformation.
Variable name User::uvSrcCount (Select a variable from drop down list to hold row
count)
9. Click Ok
Page 48
14. Drag and drop RowCount transformation and configure it by following the below
mentioned steps,
15. Select Case1 from Input and output Selection Wizard.
16. Set, Variable: uvDst1Count
17. Drag and drop OLEDBDestination and configure it,
Connection: Provide Destination Connection Manager
Table: If table exists, then select a table from drop down list or click New to create a
new table.
18. In Create table editor, rename the table as DestinationTbl2, select Mappings page and
click Ok.
19. Drag and drop RowCount transformation and configure it by following the below
mentioned steps,
20. Select Conditional Split Default Output from Input and output Selection Wizard.
21. Set, Variable: uvDst2Count
22. Drag and drop OLEDBDestination and configure it,
Connection: Provide Destination Connection Manager
Table: If table exists, then select a table from drop down list or click New to create a
new table.
23. In Create table editor, rename the table as DestinationTbl2, select Mappings page and
click Ok.
24. Finally, the package Data flow definition looks like the below shown diagram,
Page 49
As of now, actual ETL business login has been implemented. But, I would like to add few
more enhancements to the same package to capture below log details into a dbo.SSIS_Log
table,
a.
b.
c.
d.
e.
f.
g.
Solution Name
Package Name
Table Name
Source Count
Destination Count
Status
LastExecutedDate
25. In the same the package, Control Flow, Drag and drop Data Flow Task and rename it DFT
Test Condition. Make a Precedence Constraint (connection) between both the Data Flow
Tasks.
26. Double click on DFT Test Condition and in Data Flow Tab, drag and drop OLEDBSrc and
provide the following settings to configure it,
i. OLEDB Connection: Provide New Connection Manager (Sys.AdventureWorks)
ii. Data Access Mode: SQL Server
iii. SQL Command: Select MAX(LastExecutedDate) as LastExecutedDate from
DestinationTbl2
27. Drag and drop Derived Column Transformation and define the following expressions and
new columns for log table, and click Ok.
Page 50
Expression
(DT_STR,50,1252)@[User::uvSolutionName]
(DT_STR,50,1252)@[System::PackageName]
(DT_STR,50,1252)@[User::uvTableNames]
@[User::uvSrcCount]
@[User::uvDst1Count] + @[User::uvDst2Count]
28. Drag and drop Conditional Split, to check below condition, and click Ok
i. Condition: [Source Count] == [Destination Count]
ii. Output Name: Source Is Destination
iii. Default Output Name: Source Is Not Destination
29. Drag and drop Derived column, to derive Status field which nor in format of variable
or column,
i. Expression: (DT_STR, 10, 1252)"Success"
ii. Derived Column Name: Status
30. Drag and drop Derived column, to derive Status field which nor in format of variable
or column,
i. Expression: (DT_STR, 10, 1252)"Failure"
ii. Derived Column Name: Status
31. Drag and drop Union All transformation, to merge the data from multiple sources into
single destination, which has similar structure. Click Ok
32. Drag and drop OLEDB Destination, and configure it with the following settings,
i. Connection: Sys.AdventureWorks
ii. Destination Table: dbo.SSIS_Log
Page 51
Page 52
Excel Source: Excel source adapter/component is used to extract data from excel work
book.
Note: Prepare an Excel 2003 version file with the following information and save it at any
shared location (C:\Files\Students Details.xls)
Sno
Name
Class
Balaji
MCA
Balu
MBA
Nikhila
MS
Pujitha
MD
Jnanesh
MD
Balaji
Mba
Balaji
Mbbs
Lekhasr
ee
MSc
Balaji
MS
10
Balaji
MCA
Page 53
Page 54
Scenario duplicate
a flat file
Aggregate
1: How to remove
rows or records in
source using
Transformation.
In above
Create a
(Project
New SSIS
rename it as
created Project,
New SSIS Package
Menu Select
Package) and
FFile_RemoveDuplicateRows_Aggregate.dtsx
1. In Control Flow tab: Drag and drop a Data Flow Task and rename it as DFT Data
Conversion.
2. Double Click on Data Flow Task or Right Click on Data Flow Task and Select Edit to
navigate to Control Flow tab.
3. In Data Flow Tab, from Data Flow Source section (in Toolbox, shortcut key is Alt+Ctrl+x),
drag and drop Flat File Source adapter/component.
4. Right click on Flat File Source and set the following setting to configure Flat File Source,
a. Connection Manager: Flat File Connection for Student Details
b. Description: Flat File Connection for Student Details
c. Click Browse and navigate to the path where flat file is located and select the
existing Flat file
(Students details.txt)
d. Check, Column Names in the first data row check box,
Page 55
Page 56
9. Click Ok.
10. Drag and drop OLEDB Destination and set the following properties to configure OLEDB
Destination as mentioned below,
i. Connection Manager: Select Destination Connection Manager
ii. Name of Table or view: Select FFAggregateData table from drop down list.
iii. Select Mapping Page and Click Ok.
11. Execute Package.
Page 57
Scenario - 2: How to remove duplicate rows or records in a flat file source using Sort
Transformation.
Note: Basically, Sort transformation is used to sort data downstream data. And also Sort
Transformation removes duplicate rows from the source data. But, In our earlier scenario,
(Aggregate Transformation), the output is not sorted. So, I want to sort and remove duplicate
rows in a Flat File.
In above created Project, Create a New SSIS Package (Project Menu Select New SSIS
Package) and rename it as FFile_RemoveDuplicateRows_Sort.dtsx
1. In Control Flow tab: Drag and drop a Data Flow Task and rename it as DFT Data
Conversion.
2. Double Click on Data Flow Task or Right Click on Data Flow Task and Select Edit to
navigate to Control Flow tab.
3. In Data Flow Tab, from Data Flow Source section (in Toolbox, shortcut key is Alt+Ctrl+x),
drag and drop Flat File Source adapter/component.
4. Right click on Flat File Source and set the following setting to configure Flat File Source,
a. Connection Manager: Flat File Connection for Student Details
b. Description: Flat File Connection for Student Details
c. Click Browse and navigate to the path where flat file is located and select the
existing Flat file
(Students details.txt)
e. Check, Column Names in the first data row check box,
Page 58
9. Click Ok.
10. Drag and drop OLEDB Destination and set the following properties to configure OLEDB
Destination as mentioned below,
i. Connection Manager: Select Destination Connection Manager
Page 59
Page 60
Double click on the bulk insert task to open the task editor. Click on connections in left tab.
2. In the connections tab, specify the OLE DB connection manager to connect to the
destination SQL Server database and the table into which data is inserted. Also,
specify Flat File connection manager to access the source file.
3. Select,
i. Column Delimiters used in the flat file : Select Comma {,}
Page 61
4. Click on the Options in the left tab of the editor, and select the Code page the file,
starting row number (First row). Also Specify actions to perform on the destination
table or view when the task inserts the data.
5. The options are to check constraints, enable identity inserts, keep nulls, fire triggers,
or lock the table.
Page 62
6. On running the package the data will get be copied from the source to the
destination. Bulk Insert doesnt have an option to truncate and load; hence you must
use an Execute SQL Task to delete the data already present in the table before
loading flat file data.
It is an easy to use and configure task but with few cons.
1. It only allows to append the data into the table and you cannot perform truncate and
load.
2. Only Flat file can be used as source and not any other type of databases.
3. Only SQL Server Databases can be used as destination. It doesnt support any other
files/ RDBMS systems.
4. A failure in the Bulk Insert task does not automatically roll back successfully loaded
batches.
Note: Only members of the SYSADMIN fixed server role can run a package that contains a
Bulk Insert task.
Page 63
Grid
Histograms
Scatter plot charts
Column charts
These types of data viewers tend to be useful for more analytical types of data review, but
for basic troubleshooting, the grid data viewer is often the best place to start.
To create a grid data viewer, open the editor for the data path on which you want to view the
data, then go to the Data Viewers page, as shown below.
The Data Flow Path editor is where you add your data viewers, regardless of the type. To add
a data viewer, click the Add button to launch the Configure Data Viewer dialog box,
shown in Figure 5. Here you select the type of viewer you want to create and provide a name
for that viewer.
Page 64
After you select the Grid option from the Type list and provide a name, go to the Grid tab.
This is where you determine what columns you want to include in the grid. At this point,
were interested only the BusinessEntityID and FullName columns because those are the
columns in our target table.
Page 65
After you specify the columns to include in the grid, click OK. Youll be returned to the Data
Flow Path Editor. The new grid data viewer should now be displayed in the Data Viewers
list. In addition, a small icon is added next to the data path.
When you debug a package in which a data viewer has been defined, the package will stop
running at the viewers data path and a window will appear and display the data in that part
of the data flow.
Page 66
Notice that the data viewer displays the BusinessEntityID and FullName values for each row.
You can scroll down the list, detach the viewer from the data flow, resume the data flow, or
copy the data to the clipboard. The data itself and the ultimate outcome of the package are
unaffected.
Page 67
Lookup Transformation:
The Lookup transformation performs lookups by joining data in input columns with columns
in a reference dataset. We use the lookup to access additional information in a related table
that is based on values in common join columns.
Lookup transformation dataset can be a cache file, an existing table or view, a new table, or
the result of an SQL query.
Note: Lookup transformation is used to maintain both source and target or destination
tables synchronize. That means, if any rows/record existing in both source and destination
tables and which matches the join condition, then the row will be updated and all
unmatched rows will be inserted to destination system.
Steps to configure Lookup transformation:
Open SQL Server Management Studio (SSMS) and run/execute the below SQL query to
create a destination table before start configuring Lookup transformation,
USE [AdventureWorks]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Lookup_Destination](
[ProductCategoryID] [int] NOT NULL,
[Name] [nvarchar](50) NULL,
[rowguid] [uniqueidentifier] NULL,
[ModifiedDate] [datetime] NULL
) ON [PRIMARY]
GO
In above created Project, Create a New SSIS Package (Project Menu Select New SSIS
Package) and rename it as Lookup_To Make_both_Source_and_Destination_Sync.dtsx
1. In Control Flow tab: Drag and drop a Data Flow Task and rename it as DFT Data
Conversion.
2. Double Click on Data Flow Task or Right Click on Data Flow Task and Select Edit to
navigate to Control Flow tab.
3. In Data Flow Tab, from Data Flow Source section (in Toolbox, shortcut key is Alt+Ctrl+x),
drag and drop OLEDB Source adapter/component and rename it OLEDBSrc1. And set the
following setting to configure OLEDB Source.
Note: OLEDB Source component is used to extract the data from any relational database
using OLEDB provider.
OLEDB Connection Manager, click New (to create a new connection as this package a
new)
Click New In Connection Manager Editor,
Server Name: Localhost/Servername/.
Page 68
SQL Comment: Provide the following query to extract/read the data from specified
SELECT * FROM Production.ProductCategory WITH (NOLOCK) and click Build Query
click Ok.
4. Drag and drop Lookup transformation and make pipeline between OLEDBSrc and Lookup
transformation.
5. In Lookup, Select Connection Page and specify connection.
6. Check Use Results of an SQL Query radio button and provide the following reference
SQL statement to join with source table and Click Ok to save the changes. Please refer the
below screenshot for further details,
Page 69
7. Drag and drop OLEDB Command Transformation and make a pipeline connection between
Lookup and OLEDB Command transformation to update matched rows to destination.
Configure the OLEDB Command Transformation by providing the following steps,
8. In, Input and Output Selection wizard, select Output: Lookup Match Output and
click Ok
9. Now, let us see how to configure OLEDB Command Transformation,
In Connection Managers Page: Select Destination Connection Manager
In Component Properties Page,
SQL Command: UPDATE dbo.Lookup_Destination set Name = ? Where
ProductCategoryId = ?
(Here, ? means, Parameter in SSIS)
Page 70
Page 71
Page 72
Lookup Output
The Lookup transformation has the following outputs:
Match output- It handles the rows in the transformation input that matches at least
one entry in the reference dataset.
No Match output- It handles rows in the input that do not match any entry in the
reference dataset.
As mentioned earlier, if Lookup transformation is configured to treat the rows without
matching entries as errors, the rows are redirected to the error output else they are
redirected to the no match output.
Page 73
SCD is Slowly Changing Dimension. As the name suggests, a dimension which changes
slowly. For Example, say there is a table Employee, which stores information regarding
employee as below:
BusinessEntityID, NationalIDNumber, First_Name, last_Name LoginID, OrganizationNode
OrganizationLevel, JobTitle, BirthDate, MaritalStatus, Gender, HireDate, SalariedFlag
CurrentFlag, ModifiedDate
In this Employee table, the data for an employee doesn't change very often, but yes we
cant say that the changes wont be there. The changes, which may happen, are
Last_Name changes.
The employee gets promotion and job designation changes and organization level
changes.
The columns which doesn't change except if we assume that no mistake happens
Emp ID
First Name
Page 74
Last Name
Rajan
Gupta
Ranjan
Gupta
This SCD transformation directs these rows to an output named Changing Attributes
Updates Output.
Type 2 (historical attribute): when we need to maintain the history of records,
whenever some particular column value changes.
For example the employee gets promotion, designation changes and organization level
changes. In such case we need to maintain the history of the employee, that with which
designation he joined, and when his designation and organizational level changes.
For these kinds of changes, there will be multiple records for the same employee with
different designation. Then to indentify the current records, we can either add a column as
Status, which will be Current for the current or latest records, Or else we can add two
column as start date and end date (expiry date), through which we can maintain history of
employees records. This SCD directs these rows to two outputs: Historical Attribute
Inserts Output and New Output.
EmpID
FirstName
DEsignation
StartDate
EndDate
Status
Ranjan
Graduate Engineer
20-01-2010
25-01-2011
Expired
Ranjan
Analyst Programmer
25-01-2011
25-01-2012
Expired
Ranjan
Business Analyst
25-01-2012
1-01-2099
Current
Page 75
Page 76
Page 77
7. Click Next
8. Set the following properties to manage the changes to column data in your slowly
changing dimensions by setting the change type for dimension columns,
Dimension Columns
BirthDate
EmployeeId
Gender
Marital Status
Salaried Flag
SickLeavesHours
Title
Vacation Hours
Change Type
Fixed Attribute
Fixed Attribute
Fixed Attribute
Changing Attribute
Changing Attribute
Historical Attribute
Changing Attribute
Historical Attribute
Page 78
Page 79
Page 80
Page 81
2. In the SSIS Property Pages dialog box, select Build option under the Configuration
Properties node and in the right side panel, provide the folder location where you want the
SSIS package to be deployed within the OutputPath. Click OK to save the changes in the
property page.
3. In Solution Explorer, right click the SSIS Package and then click Set as Startup Object
option as shown in the snippet below.
Page 82
4. Finally to execute the SSIS package, right click the package within Solution Explorer and
select Execute Package option from the drop down menu as shown in the snippet below.
Page 83
Page 84
The Execute Package Utility is also used when you execute the SSIS package from the
Integration Services node in SQL Server Management Studio.
Page 85
Page 86
3. Click OK to save the job step and click OK once again to save the SQL Server Agent Job
4. That's it now you can execute the SQL Server Agent Job which will internally execute the
SSIS package.
Page 87
The simplest approach to deployment is probably to deploy to the file system. As SSIS
package is actually just an XML file and it can simply be copied from its project location to a
folder on the deployment target. You can use the DOS COPY command, Windows Explorer,
etc. to perform the copy operation. The package store is a particular folder on the file
system; the default for SQL Server 2005 is C:\Program Files\Microsoft SQL
Server\90\DTS\Packages.
Note: SSIS packages deployed to SQL Server are stored in the msdb database.
There are three ways to deploy our packages:
Use SQL Server Management Studio (SSMS) (Using Import Package option)
Page 88
Select Properties from the popup menu. Click Deployment Utility in the Configuration
Properties list and fill in the dialog as follows:
Page 89
The above files represent the deployment. You can copy them to the deployment target
then double click on the Tutorial-Sample-1.SSISDeploymentManifest file to perform the
deployment.
Deploying SSIS Packages with SSMS
SQL Server Management Studio (SSMS) can be used to deploy SSIS packages to SQL Server
or to the Package Store.
To begin launch SSMS and connect to Integration Services. Note that the SQL Server
Integration Services service must be running in order to do this. You will see the following in
the Object Explorer:
As you can see there are two nodes under Stored Packages: File System and MSDB.
a. File System is actually the package store with a default location in SQL Server 2005 of
C:\Program Files\Microsoft SQL Server\90\DTS\Packages.
Page 90
Page 91
In the examples that follow, I will show how to deploy the CreateSalesForecastInput.dtsx
package to the file system, package store, and SQL Server.
To deploy to the file system, you could use the DOS COPY command, Windows Explorer, etc.
or the following DTUTIL command (all on one line):
DTUTIL /FILE CreateSalesForecastInput.dtsx
/COPY
FILE;C:\temp\CreateSalesForecastInput.dtsx
Replace the path C:\temp as appropriate.
To deploy to the package store, type the following command (all on one line):
DTUTIL /FILE CreateSalesForecastInput.dtsx
/COPY
DTS;CreateSalesForecastInput
To deploy to SQL Server, type the following command (all on one line):
DTUTIL /FILE CreateSalesForecastInput.dtsx
/COPY
SQL;CreateSalesForecastInput
The above command deploys to the default SQL Server instance on the local machine. To
deploy to a different SQL Server add the command line parameter /DESTSERVER
"SERVERNAME\INSTANCENAME".
Page 92
For Loop Container: Its a basic container that provides looping functionality. A For
loop contains a counter that usually increments (though it sometimes decrements), at which
point a comparison is made with a constant value. If the condition evaluates to True, then
the loop execution continues.
The Foreach Loop container: It enumerates a collection and repeats its control
flow for each member of the collection. The Foreach Loop Container is for situations where
you have a collection of items and wish to use each item within it as some kind of input into
the downstream flow.
Page 93
The AssignExpression is the last expression used in the For Loop. It is used to
change the value of the variable used in the EvalExpression. This expression is evaluated for
each pass through the loop as well, but at the end of the workflow. This expression is
optional
Example Scenario:-We will create a table with the name Data having fields SNo and Date.
Then, with the help of For Loop Container, we will increment the values of SNo from 1 to 10
(iterative process) and insert them into our Data table.
Solution:
1. Open SQL Server Management Studio (SSMS) and Connection to Database Engine.
2. Run the below mentioned SQL query to create a new table.
USE [AdventureWorks]
GO
GO
3. In above created Project, Create a New SSIS Package (Project Menu Select New SSIS
Package) and rename it as FLoopContainer_With_ExecuteSQLTask.dtsx
4. In Control Flow tab: Create a variable (uvCounter) of type Int32, as mentioned below
5. Drag and drop For Loop Container and set the following properties,
6. In Control Flow tab: Drag and drop Execute SQL Task, and configure it by providing the
following
settings,
Page 94
SQL Statement :
INSERT INTO [AdventureWorks].[dbo].
[FEContainer_UsingESQLTask]
([SNo]
,[Name]
,[Class])
VALUES
(? -- Parameter1
,'Kelly Technology_' + CAST (? AS VARCHAR)
---Parameters2
,'MSBI')
GO
7. Select Parameter Mapping Page, Click Add to add parameters, and click Ok
and
statement.
8. Execute Package.
9. For results, Connect to SSMS and run the following query,
SELECT * FROM FEContainer_UsingESQLTask WITH (NOLOCK)
Page 95
4. Click Ok.
5. Now, Execute Package.
6. We can observe that, only one specified package would be executed. But, if you
want execute all the package/files at the specified location; we need to use For
Each Loop Container. Now, Let us see how to configure For Each Loop Container.
7. In Control Flow tab; drag and drop For Each Loop Container and set the following
properties,
In General Page :
Name : FELC Loop Through multiple Pacakges
Description : FELC Loop Through multiple Pacakges
In Collection Page:
Enumerator : Select For Each File Enumerator
Folder : Specify the location where files/packages are located
(H:\SSIS Packages\Packages)
Page 96
8. In Control Flow tab; drag and drop, already configured Execute Package Task to
For Each Loop Container to loop through Execute Package task for every package
at the specified location.
9. In Connection manager section, select Package Connection and press F4 for
properties, and set the following properties to create package connection
dynamically (at run time),
Page 97
SSIS
1. In above created Project, Create a New SSIS Package (Project Menu Select New
Package) and rename it as FELoopContainer_To Loop through Multiple Excel
Files.dtsx
2. Create multiple excel files (with proper data) and save them in a location
(H:\SSIS Packages\Files)
3. In Control Flow tab; Drag and drop Data Flow Task
4. In Data Flow tab; Drop and drop Excel Source component and configure it as
mentioned
below,
and
Page 98
Variable
Name
Scope
Data
Type
uvExcelFiles
Package
String
uvFullPath
Package
String
uvSrcPath
Package
String
Value
H:\SSIS Packages\Files\Students
On2004.xls
H:\SSIS Packages\Archive
8. Now, Lets see how to configure, For Each Loop Container to loop through multiple
excel workbooks,
9. Drag and drop For Each Loop Container, and set the following properties,
a. In Collection Page
i. Enumerator -- Foreach File Enumerator
ii. Folder -- H:\SSIS Packages\Files
iii. Files -- *.xls
Page 99
13. In Expression Builder, build the following expressions to create Excel Connection,
"Provider=Microsoft.Jet.oLEDB.4.0;Data Source= + @[User::uvExcelFiles] +
";Extended Properties=\"Excel 8.0;HDR=YES\";"
Page 100
17 In Properties Editor,
i. Expression Click (Browse or Eclipse)
ii. Property Select Connection String
iii. Expression Click (Browse or Eclipse)
18 In Expression Builder, build the following expression to build value of the variable at
runtime,
Page 101
19. In control flow; drag and drop File System Task to perform Create Directory operation,
and set the following properties as mentioned in the below screen shot,
i. Operation : Create directory
ii. IsSourcePathVariable: True
iii. Source Variable: Select User::uvFullPath
iv. UseDirectoryIfExists: True
v. Name: FST Create new Directory
vi. Description: FST Create new Directory
20. Click Ok and make connection between File System Task and For Each Loop Container
21. Drag and drop File System Task inside For Each Loop Container and after Data Flow Task
and configure it by providing the following setting,
i. Operation: Copy File
ii. IsSourcePathVariable: True
iii. Source Variable: Select User::uvExcelFiles
iv. IsDestinationPathVariable: True
Page 102
Page 103
3. Scenario: Extract data from multiple sheets in a single excel workbook and load the
data in to destination table. That means, loop through multiple sheets in excel workbooks
(*.xls) which is located in a file system.
SSIS
and
1. In above created Project, Create a New SSIS Package (Project Menu Select New
Package) and rename it as FELoopContainer_To Loop through Multiple Sheets
In Excel File.dtsx
2. Create multiple excel files (with proper data) and save them in a location
(H:\SSIS Packages\Files)
3. In Control Flow tab; Drag and drop Data Flow Task
4. In Data Flow tab; Drop and drop Excel Source component and configure it as
mentioned
below,
Page 104
Scope
Package
Data
Type
String
Value
Sheet1$
19. In control Flow tab; Drag and drop For Each Loop Container, and set the following
properties,
a. In General Page:
i. Name : FELC Loop Through Mutliple Excle Sheets
ii. Description : FELC Loop Through Mutliple Excle Sheets
b. In Collection Page :
i. Enumerator : Foreach ADO.NET Schema Rowset Enumerator
ii. Connection : Select New Connection Click New Provider : Select
.Net Provider for OLEDB\Microsoft Jet 4.0 OLEDB Provider
iii. Database File Name : Click Browse File Name (Select All Files (*.*))
and select the excel file.
Page 105
Page 106
Page 107
21. In Variable Mapping Page, set the below mentioned in screen shot, and click Ok.
22. In Data Flow tab; Open Excel Source and set the following properties,
Data access mode: Select Table name or View name from Variable
Variable Name : Select User::uvExcelSheets
23. Finally, we could find 3 connection managers as mentioned below screen shot.
Page 108
as
mentioned below,
b. CheckpointFileName: Specifies the full path and filename of your checkpoint file.
c. CheckpointUsage: Specifies when to use checkpoints. The property supports the
following three options:
Page 109
i.
ii. IfExists: A checkpoint file is used if one exists. This option is the one most
commonly used if enabling checkpoints on a file.
iii. Always: A checkpoint file must always be used. If a file doesnt exist, the
package fails.
d. SaveCheckpoints: Specifies whether the package saves checkpoints. Set to True to
enable checkpoints on the package.
e. And also, we need to set two more properties with respect to each and every
container or task in the package,
f. Select Execute SQL Task1 (first task in our example) and press F4 for properties and
set the following two properties,
i. FailPackageOnFailure True
ii. FailParentOnFailure True
g. Execute Package.
Logging in Packages:
In the above package, lets see how to create new loggings,
We can maintain log about package & system information, various events for the container
can also be logged.
We can enable logging in two ways as shown in below two images,
Page 110
Page 111
Select Provider type: SSIS log provider for Text files click Add
ii. You can give the path of existing flat file /create new flat file
under Configuration.
iii. For logging the information into flat file, select the options as shown in below
image.
Page 112
i.
Select Provider type: SSIS log provider for XML files click Add
ii. You
can
give
the
path
of
existing
XML
file
/create
new
XML
file
under Configuration.
iii. For logging the information into XML file, select the options as shown in below
image.
Page 113
iv. Execute the package and open the XML file to see the logged information.
Select Provider type: SSIS log provider for Windows Event Log and
Page 114
v. Right Click Control Flow tab and select Log Events, you will notice as shown
below,
i.
Select Provider type: SSIS log provider for SQL Server and
Page 115
Execute
SQL
Task,
contains
and
the Description property. The Name property refers to the task name. You should name the
task something suitable. On my system, I named the task Get ResultSet. I then added a
description to the Description property to explain what the task does.
In the Options section, Lets go ahead with the default property values.
The next section on the General page is Result Set. Notice that this section includes only
the ResultSet property. The property lets you select one of the following four options:
Fullresultset: The query returns a result set that can contain multiple rows.
The option you select depends on the results of the query you pass into the Execute
SQL task. For this exercise, our query will return only a single value. Consequently, we
will choose the Single row option.
Next, we need to configure the properties in the SQL Statement section. Table 1 shows
the values you should use to configure these properties.
Property
Connection
SQLSourceType
SQLStatement
Value
AdventureWorks (or whatever you named the connection
manager you created earlier)
Direct input
This means well type the code straight in and not use a
stored procedure.
Because weve selected the Direct input option, we need to
enter a T-SQL statement for this option. Ive used the following
statement, which returns a single value:
SELECT MAX(EmployeeID) AS [MaxEmployeeId]
FROM HumanResources.Employee
IsQueryStoredProcedure
This option is greyed out because we selected Direct
Page 116
BypassPrepare
Value
input for the SQLSourceType property. Had we
selected Stored Procedure, this property would be available
and the SQLStatement property would be greyed out.
The property defaults to False. If you change the value
to True, you can click the Parse Query button to verify that
your T-SQL statement is valid.
Our next step is to associate our result set value with a variable that will store the value
we retrieve from the database. To do this, go to the Result Set page of the Execute SQL
Task Editor.
The main grid of the Result Set page contains two columns: Result Name and Variable
Name. Click the Add button to add a row to the grid. In the Result Name column, enter
the column name returned by your query (MaxEmployeeId). In the Variable
Name column, select the User::MaxEmployeeId variable. Your Result Set page should
now look similar to the one shown in Figure 6.
If our single-row result set contains multiple columns, we would have had to map a
variable to each column. However, because we returned only one value, we needed only
one mapping.
Once youve associated your result set value with a variable, click OK to close
the Execute SQL Task Editor. You task should now be set up to return a single-row
result set. Now we need to do something with that result set!
Now, lets work with a Single-Row Result Set:
Our next step is to drag a new Execute SQL task onto our design surface so we can use
the result set returned by the first Execute SQL task. So add the task, and then connect
the precedence constraint (the green arrow) from the first task to the new one. Next,
right-click the second task and click Edit to open the Execute SQL Task Editor.
Page 117
In the General section, provide a name and description for the task. (I named the
task Using Result Set.) For the ResultSet property, stick with the default value, None.
In this case, the task wont be returning a result set. Instead, well be using the results
returned by the previous task.
Now lets look at the SQL Statement section shown in Figure 8. Notice that, for
the SQLStatement property, I entered the following T-SQL code:
As you can see, were executing the UpdateSSISLog stored procedure. Notice, however,
that we follow the name of the stored procedure with a question mark (?). The question
mark serves as a placeholder for the parameter value that the stored procedure requires.
You cannot name parameters within the actual query, so we have to take another step to
provide our value.
Go to the Parameter Mapping page of the Execute SQL Task Editor. On this page,
you map the parameters referenced in your queries to variables. You create your
mappings in the main grid, which contains the following five columns:
Page 118
Variable Name: The variable that contains the value to be used for the
parameter. In this case, well use the User::EmpNum variable, which contains the
result set value returned by the first Execute SQL task.
Direction: Determines whether to pass a value into a parameter (input) or return
a value through the parameter (output)
Data Type: Determines the type of data provided from the variable. This will
default to the type used when setting up the variable.
Parameter Name: The name of the parameter. The way in which parameters are
named depends on your connection type. When running a T-SQL statement
against a SQL Server database through an OLE DB connection, as were doing
here, we use numerical values to represent the statements parameters, in the
order they appear in the statement, starting with 0. In this case, because theres
only one parameter, we use 0.
Parameter Size: The size of the parameter if it can be a variable length. The
default is -1, which lets SQL Server determine the correct size.
Once youve mapped your variable to your parameter, the Parameter Mapping page
should look similar to the one shown in Figure 8.
When youre finished configuring the Execute SQL task, click OK.
Your package should now be ready to run. Click the green Execute button. When the
package has completed running, query the SSISLog table and verify that a row has been
added that contains the expected results.
Page 119
2- Add an Execute SQL Task, set connection as OLEDB to the AdventureWorks Database,
write this query in SQL Statement:
Page 120
SELECT EmployeeID,NationalIDNumber,ContactID
FROM HumanResources.Employee
FOR XML RAW('Facility'),Root('Extract'),Elements
Set Result Set properties to XML.Then go to Result Set tab, and do this mapping:
Result Name -- 0
Variable Name -- User::XMLData
Page 121
3- Add a Script Task after execute SQL task, set language as C#. and set ReadOnlyVariables
as User::XMLData .
Page 122
When the package is saved, any property that is tagged with Sensitive="1" gets handled per
the ProtectionLevel property setting in the SSIS package. The ProtectionLevel property can
be selected from the following list of available options (click anywhere in the design area of
the Control Flow tab in the SSIS designer to show the package properties):
1. DontSaveSensitive
2. EncryptSensitiveWithUserKey
3. EncryptSensitiveWithPassword
4. EncryptAllWithPassword
5. EncryptAllWithUserKey
Page 123
Page 124
The above connection manager is for a SQL Server database that uses SQL Server
authentication; the password gives the SSIS package some sensitive information that must
be handled per the ProtectionLevel package property.
Now let's discuss each ProtectionLevel setting using an SSIS package with the above OLE
DB Connection Manager added to it.
1. DontSaveSensitive
When you specify DontSaveSensitive as the ProtectionLevel, any sensitive information is
simply not written out to the package XML file when you save the package. This could be
useful when you want to make sure that anything sensitive is excluded from the package
before sending it to someone. After saving the package using this setting, when you open it
up and edit the OLE DB Connection Manager, the password is blank even though the Save
my password checkbox is checked:
Page 125
2. EncryptSensitiveWithUserKey
EncryptSensitiveWithUserKey encrypts sensitive information based on the credentials of the
user who created the package; e.g. the password in the package XML would look like the
following (actual text below is abbreviated to fit the width of the article):
<DTS:PASSWORD Sensitive="1" DTS:Name="Password"
Encrypted="1">AQAAANCMnd8BFdERjHoAwE/Cl+...</DTS:PASSWORD>
Note that the package XML for the password has the attribute Encrypted="1"; when the
user who created the SSIS package opens it the above text is decrypted automatically in
order to connect to the database. This allows the sensitive information to be stored in the
SSIS package but anyone looking at the package XML will not be able to decrypt the text
and see the password.
There is a limitation with this setting; if another user (i.e. a different user than the one who
created the package and saved it) opens the package the following error will be displayed:
Page 126
If the user edits the OLE DB Connection Manager, the password will be blank. It is important
to note that EncryptSensitiveWithUserKey is the default value for the ProtectionLevel
property. During development this setting may work okay. However, you do not want to
deploy an SSIS package with this setting, as only the user who created it will be able to
execute it.
3. EncryptSesnitiveWithPassword
The EncryptSensitiveWithPassword setting for the ProtectionLevel property requires that you
specify a password in the package, and that password will be used to encrypt and decrypt
the sensitive information in the package. To fill in the package password, click on the button
in the PackagePassword field of the package properties as shown below:
You will be prompted to enter the password and confirm it. When opening a package with a
ProtectionLevel of EncryptSensitiveWithPassword, you will be prompted to enter the
password as shown below:
Page 127
Note that the entire contents of the package is encrypted and the encrypted text is shown in
the CipherValue element. This setting completely hides the contents of the package. When
you open the package you will be prompted for the password. If you lose the password
there is no way to retrieve the package contents. Keep that in mind.
When you execute a package with this setting using DTEXEC, you can specify the password
on the command line using the /Decrypt password command line argument.
5. EncryptAllWithUserKey
The EncryptAllWithUserKey setting for the ProtectionLevel property allows you to encrypt
the entire contents of the SSIS package by using the user key. This means that only the
user who created the package will be able open it, view and/or modify it, and run it. After
saving a package with this setting the package XML will look similar to this:
Page 128
Note that the entire contents of the package are encrypted and contained in the Encrypted
element.
6. ServerStorage
The ServerStorage setting for the ProtectionLevel property allows the package to retain all
sensitive information when you are saving the package to SQL Server. SSIS packages saved
to SQL Server use the MSDB database. This setting assumes that you can adequately secure
the MSDB database and therefore it's okay to keep sensitive information in a package in an
unencrypted form.
Page 129
Once you are done with creating the basic structure of the package and have added
the common components, you need to save a copy of this package at the following
locations based on the version of SQL Server you are using:
For SQL Server 2008
<<Installation drive>>:\Program Files (x86)\Microsoft Visual Studio
9.0\Common7\IDE\PrivateAssemblies\ProjectItems\DataTransformationProject\DataTransform
ationItems
OR
<<Installation drive>>:\Program Files\Microsoft Visual Studio
9.0\Common7\IDE\PrivateAssemblies\ProjectItems\DataTransformationProject\DataTransform
ationItems
Page 130
You need to specify the drive location where Business Intelligence Development
Studio (BIDS) or SQL Server Data Tools (SSDT) has been deployed. Please note, as
BIDS or SSDT runs locally on client machine, you need to copy the template
package to the above location on all the development machines you want it to use.
For this example we are naming the template package
"SamplePackageTemplate.dtsx".
You are not restricted to deploying only one template. You can deploy as many
templates as you want to the folders listed above and reuse them as needed.
In the Add New Item dialog box, you will notice the deployed package template as
shown below. You can select it and specify a name for the package for which the
template will be used and click on the Add button to add the new package to your
project based on the selected template. That's all you have to do. You now have a
package that is pre-configured and you can now customize it for your specific need.
Please note, the modifications that are done in the new package do not impact the
Kelly Technologies, Hyderabad.
Page 131
If you are using SQL Server 2012, when you add a new item you will see the
template appearing in the Add New Item dialog box as shown below. Select the
template and specify the name for the new package which will be based on this
template.
Page 132
Generate Unique ID
If you are using SQL Server 2005 or 2008 then you should generate a unique ID.
This is recommended because it helps in analyzing log data with better
differentiation for each package. To generate a unique ID value for the package,
click the ID in the Properties pane, and then click Generate New ID.
In SQL Server 2012 when you add a package based on a template, SSDT generates
a unique ID for each package and hence you don't need to do it separately.
Page 133