In SSIS, can I change the project.param value? - ssis

I can see and I can modify the values of the project variables, but my question is ... Can I modify the value of the parameters Project.params or Package Params? I do not find that option.
For example, I create a project parameter called StopExecution of type Boolean with its value in False, and when an error occurs in one of my SSIS steps, can I change the value of the Project.param StopExecution to True?, with this functionality in my other package called Package2.dtsx, before starting its execution when I finish my first package called Package1.dtsx (both are executed for a SQL job) Can I validate if my Package2.dtsx has to be executed?
Can you help me? I can do that?

No. Project Parameters are read-only; you can specify its value at package start.
You are looking for some global parameter which you can change in child package. File, SQL table or Web service could be such global storage; you write some value to an SQL table and read it later.
There is a guideline how to use SSIS parent package variables from child package and update parent package variable from child. You can try it, but this scenario relies on variable scope hack.

Related

SSIS Setting OLE_DB Connection string from variable is not working getting error code dts_e_cannotacquireconnectionfromconnectionmanager

I have a parent child package situation where the parent is reading a SQL Server task table. Loops through the tasks and gets the connection string needed for the the task and passes it to the child package. I have created and set a variable in the parent package. I have also created and set a variable n the child package in a Script Task. The Variable is set to the Connection String of my OLE_DB connection in an expression (Package.DelayValidation = True). After the Script task runs(and works..I displayed a message box with the correct value) I run a Data Flow Task which trys to read the database using the connection string. This is where the "error code dts_e_cannotacquireconnectionfromconnectionmanager" happens. I know I have to be missing something, just can not put my finger on it.
Since both packages are available in a single project, try to select Project Reference ,in the parent package, as the ReferenceType and in the PackageNameFromProjectReference enter your child .

Execute Package Task - Is there a way to bind the Child Package parameter to a constant?

I want to execute a package multiple times, each time using a different value for the Child package parameter.
Is there anyway to do it?
I could create a variable to hold the value and use an Expression Task to update it after each package execution but I'd like to avoid it if possible.
The desired outcome would be:
Execute Package Task requires that child package parameters should be bound to variables only, no constant values.
You could create a string variable with desired value, and map it at Execute Package Task. Child package does not alter variables of the Parent package (unless you do some tricks), and the variable will be kept intact.
You also can use a system variable instead of constant and user dummy variable:
System::TaskName
and give a name "Patient" to your Execute Package Task.
In this case you do not have to pollute your parent package with variables but also can reuse the same approach for other child packages
I carried it out the following way:
I've loaded all these values to a record set.
Then Iterated on this record set using for each sequence container.
Finally, called the package in the sequence container and assigned the value to the package parameter.

How to bind a parameter to child packages when they are dynamically chosen

I have a parent package which contains an Execute Package Task that executes packages using a Foreach Container through the PackageName expression, i.e. package names are populated at run-time. Each of these packages have the same parameter I want to populate, but I am unable to bind it since there is no package name explicitly stated in the task. I've set DelayValidation to True, but it does not resolve this issue.
So essentially the desired workflow is this:
Execute SQL Task to get list of packages to run, save result set to ADO
Iterate over each item in ADO, one of the values is package name, other is param value
Execute the current package with the parameter value from current item
Is this possible?
Go to execute package task and select the child package name from the dropdown(packagenamefromprojectReference) first before making the package name dynamic.
Now do parameter bindings. Once all the parameters are bind then go to expressions and select packagename and give variable name. This sets your package execute task.
Now set delay validation as true.

Variable in Data flow task in SSIS

I have developed SSIS package where in I have script component and Data flow task. Script component take 2 input variables namely Db2Con, SQLCon which are DB2 connection string and SQL Connection String. In this script component, I am dynamically generating Query and saving its value to the output variable namely DB2Qry. Now, In Data flow task, I am using this variable for source component.But it is not allowing me to do so with an Error "SSIS Error Code DTS_E_OLEDBERROR". In script component, I have made this variable as 'ReadWrite Variable.' Please suggest if I am missing something.
SQL's EvaluateAsExpression should be set to FALSE. You're not putting an expression into the variable, As you're assigning a static value through your script.
and you need to manually set a "default" value for your SQL variable in the Variables pane, otherwise the OLE DB Source has nothing to use for the SQL statement at design time

SSIS 2005 - How to check a file to see if a files does not exist

How do you check to see if a file does not exist in SQL Server Integration Services 2005?
Is there a native SSIS component which will just do this for you?
I have checked for file existence this using the Script Task and then branch accordingly.
You can do something like
If System.IO.File.Exists("\\Server\Share\Folder\File.Ext") Then
Dts.TaskResult = Dts.Results.Success
Else
Dts.TaskResult = Dts.Results.Failure
End If
Although there are no native components for this, there are several third party components for SSIS that you can use for this purpose.
The File System Task in SSIS is basically for move, copy, delete, etc., but does not support file existence checks.
#Raj More gave a good solution. Another way that I have used before is to create a Foreach Loop Container that loops over the file system for a file spec. If you know the name of the file you want, then you can set the name in a variable and set the spec to equal the variable in the expression tab for the Foreach Loop Container. You could also just specify or a directory or a partial file name if you don't know the exact name but know the naming convention or know there will be no other files in the folder.
If you want to take a specific action based on whether or not there is a file, then you could create a variable with a default value of 0 and create a script task in the Foreach Loop Container that increments the variable. You could also just put the commands in the Foreach Loop Container that you want to execute if you want to execute it for the existence of each individual file. If you want to take an action based on the absence of the file, then you could restrict your precedence constraint after the Foreach Loop Container so that it is restricted on constraint and expression and make it check if the counter variable is > 0.
#Raj's solution could also be used to increment the variable. Instead of using an If Else to raise an error or success result, you could do this:
C#
if (System.IO.File.Exists("\\Server\Share\Folder\File.Ext"))
{ Dts.Variables["my_case_sensitive_variable_name"].Value = Dts.Variables["my_case_sensitive_variable_name"].Value + 1;
}
VB.NET
If System.IO.File.Exists("\\Server\Share\Folder\File.Ext") Then
Dts.Variables["my_case_sensitive_variable_name"].Value = Dts.Variables["my_case_sensitive_variable_name"].Value + 1
End If
The advantage of this approach is that the package may not need to fail in the absence of a file. You could also use a variable name if the file changes that you could define either as a variable in the package or just solely created in the script task. The only short-coming of #Raj's approach is that you have to know the file name you want to check.
Another possibility is to execute a File System Task to rename the file to its existing name or copy the file to its existing location. If the file doesn't exist, then you can route the error to an action. I don't recommend this solution, but I remember using it years ago in one instance where it actually made sense. But in that particular instance, I was actually copying it to a real location.
Good luck!