Wednesday 18 May 2016

Variables in SSIS

A variable is essentially place holder that has a name, data type, scope, and value. Using variables is one of the ways where we can make a package dynamic and reusable. We ac read and changes the value of the variable within the package. Variables store values that a SSIS package and its containers, tasks, and event handlers can use at run time. The scripts in the Script task and the Script component can also use variables. The precedence constraints that sequence tasks and containers into a workflow can use variables when their constraint definitions include expressions.

Integration Services supports two types of variables:

Ø  System variables

Ø  User-defined variables and 

System variable:

System variables are predefined variable. We can’t create and changes the values of the system variables.
For seeing the system variable, Right click on the control pane and select the variable.
  
Variable window will be opened
  
By default here we are seeing the user define variable. If you want to see the system variable the click on the grid in variable
  
Variable grid option window will be open and select the show system variable.
  
See the list of variable.
   
See the name space for system variable showing System and the user define variable showing User.
System variable
Data type
Description
CancelEvent
Int32
The handle to a Windows Event object that the task can signal to indicate that the task should stop running.
ContainerStartTime
DateTime
The start time of the container.
CreationDate
DateTime
The date that the package was created.
CreatorComputerName
String
The computer on which the package was created.
CreatorName
String
The name of the person who built the package.
ExecutionInstanceGUID
String
The unique identifier of the executing instance of a package.
FailedConfigurations
String
The names of package configurations that have failed.
IgnoreConfigurationsOnLoad
Boolean
Indicates whether package configurations are ignored when loading the package.
InteractiveMode
Boolean
Indicates whether the package is run in interactive mode. If a package is running in SSIS Designer, this property is set to True. If a package is running using the DTExec command prompt utility, the property is set to False.
LocaleId
Int32
The locale that the package uses.
MachineName
String
The name of the computer on which the package is running.
OfflineMode
Boolean
Indicates whether the package is in offline mode. Offline mode does not acquire connections to data sources.
PackageID
String
The unique identifier of the package.
PackageName
String
The name of the package.
StartTime
DateTime
The time that the package started to run.
ServerExecutionID
Int64
Execution ID for the package that is executed on the Integration Services server.





The default value is zero. The value is changed only if the package is executed by ISServerExec on the Integration Services Server. When there is a child package, the value is passed from the parent package to child package.
UserName
String
The account of the user who started the package. The user name is qualified by the domain name.
VersionBuild
Int32
The package version.
VersionComment
String
Comments about the package version.
VersionGUID
String
The unique identifier of the version.
VersionMajor
Int32
The major version of the package.
VersionMinor
Int32
The minor version of the packa

User define variable:

User-defined variables are defined by package developers, and system variables are defined by Integration Services. You can create as many user-defined variables as a package requires, but you cannot create additional system variables.

We can create the user define variable as per our requirement.
  
Name: Name of the variable
Scope: scope of the variable.
Data type: Data type of the variable
Value:  fix value
Namespace:  if the variable is user define then the namespace is User if the variable is System variable then the name space is System.
Expression: we can assign the value of the variable by using expression.
If we creating the variable values variable and getting value of the variable through expression then we need to set the EvaluateAsExpression to True.
  
For creating the expression click on the expression button

Expression builder will be open
  

Here we are evaluate the expression

Click ok.
   
Value will be changed on execution time.

Variables names are case-sensitive.


No comments:

Post a Comment

If you have any doubt, please let me know.

Popular Posts