2. Why would you listen to me!
• Sr. Database Engineer.
• SQL BI & SQL Developer Trainer.
• Started with SQL Server 7.
3. Agenda
Overview (Variables / Expressions).
Variables – Data Types, scope, Namespace and naming conventions.
Variables – Debugging using Breakpoints.
Variables – User & System Variables using „Package Configurations‟.
Variables – Using .NET in a Script Task. (Control Flow)
Variables – Using .NET in a Script Component. (Data Flow)
Expressions and Dynamic SSIS.
Expressions - Operators, Functions, Literals and Casting.
Using the Expressions builder and the Expression Tester Application.
Common String, Numeric, NULL, Conditional and Date & Time examples.
Q & A.
4. Overview
Variables:
A place holder for your values, used to store and
pass values between tasks and containers
internally or between packages (child and parent
packages).
Expressions:
Anexpression is a combination of multiple
operators and functions and could reference
multiple columns or variables to yield a single
6. Variables – Date Types
Data types are .Net data types
SSIS supports the following data types:
Boolean Byte Char
DateTime DBNull Double / Decimal
Int16 Int32 Object
SByte String UInt32
UInt64 Int64 Single
http://tinyurl.com/ssisDT
7. Variables – Scope , NameSpace
A way to organize your package and limit
your variables to a certain task using
Scopes or NameSpaces.
As variables’ names are unique, you can
have the same name across multiple
‘Scopes’ or ‘Name spaces’
8. Variables – Naming Conventions
Name: Name of your variable. Preferable and
suggested to use a meaningful Camel Case name,
including its data type abbreviation, such as:
StrFName: For a string data type variable.
IntTotalSales: For an integer data type variable, you can
also specify if it‟s Int16, Int32 or Int64. (too much!)
DTSalesDate: For a Date Time variable.
BoolFileFound: For a Boolean variable, holds a flag (0
14. Expressions - Overview
used to assign values to variables, update or populate
properties at run time, define constraints in precedence
constraints, and provide the expressions used by the
For Loop container.
The language is somehow similar to the curly braces
languages (C++,C# or Java ).
Almost any task in SSIS, if not all, can use expressions
to make its properties dynamic.
“Execute SQL Task” dynamic SQL query.
“Derived Column” validate or assign value to a column.
“Conditional Split” to split a column based on a specific condition.
“Precedence Constraints“ direct the flow to a different route based on a
custom condition within the Control Flow.
18. Expressions - Literals
Hard coded info that you provide when building expressions (Numeric, String and
Boolean) to give more info about the expression‟s value.
Numeric
Numeric literals checked for decimal points before getting
casted to DT_UI4, and to DT_NUMERIC if there‟s a
decimal. To override use one of these suffixes.
19. Expressions - Literals
Boolean (True OR False)
String
Escape Description
n New Line
b Backspace
” Creates a Double Quotes
t Tab
Creates a backslash, used for URLs
20. Expressions - Operators
+ Add or (Concatenate) - Subtracts or (Negates
)
* Multiply / Divide
|| Logical OR && Logical AND
== Equal != Un Equal
?: Conditional < Less Than
> Greater Than <= Less Than or Equal
>= Greater Than or Equal & Bitwise AND
21. Expressions - Casting
Converts an expression from one data type to a
different data type. DT_BOOL True / False
Implicit - Automatically DT_DBDATE Date
Explicit – Using CAST DT_DBTIMESTA Date & Time
MP
DT_I4 Four-byte, signed
integer.
DT_DECIMAL Decimal with precision
DT_NUMERIC and scale
DT_WSTR Unicode character
http://msdn.microsoft.com/en-us/library/ms141036%28v=sql.105%29.aspx -- Data Typeshttp://msdn.microsoft.com/en-us/library/ms141260%28v=sql.105%29.aspx ---Implicit Data Type Conversion in Expressionshttp://msdn.microsoft.com/en-us/library/system.typecode.aspx --.Net data typeshttp://www.sqlservergeeks.com/blogs/RakeshMishra/sql-server-bi/247/data-types-%E2%80%93-sql-server-and-ssishttp://www.bidn.com/blogs/DevinKnight/ssis/1387/ssis-to-sql-server-data-type-translations