SSIS Variables Not Updating When Execute Package on Server - variables

I have created a package that does the following:
ExecuteSQLTask: queries db table and sets package variables from data returned
DataFlowTask starts
OleDBSource: uses package variables as parameters to call stored procedure
FlatFileDestination: uses package variables to save a tab delimited file in the correct location and filename
SendEmailTask: uses package variables to email the file as attachment to recipient
I have the following vars:
FileName
sp_Param1
sp_param2
emailRecipient
SMTPServer
At design time, each var has dummy values. When I run the package in VS, it works perfectly. I can update the values in the db table and each execution picks up the new values and works.
The problem begins when I deploy the package to the database and execute it. It appears to not be setting the variables from the db table any longer and it uses the dummy data that I used during design time. What is going on?

Related

Execute SSIS Package Script Task From Stored Procedure Get Variable Value

I have an SSIS package that takes in (through a package parameter) a value, passes it into a script task via a script variable (readonly variable), converts it to another value inside the script task, and finally writes that value out to another script variable (readwrite variable). There are no other SSIS modules in the package aside from the one script task.
What I would like to do, from outside the package (via SQL) is:
Call the SSIS package, passing in a value for my parameter and variable
Get the value of the read/write variable that is determined at the end of the script task execution
I've got step #1 working, just can't figure out #2.
How do I get the value of package variable in an SSIS package after it has executed? Is it accessible? Is it stored anywhere or can I store it somewhere in the SSIS catalog? I've tried to see if it's stored in the SSISDB.[catalog].executions table somewhere, but it doesn't seem to be.
Do I need to write that script variable to a package parameter in order to see it from SQL after execution? Could I then perhaps see it by using EXEC [SSISDB].[catalog].get_parameter_values, or does that only show parameter values before package execution? Am I going about this completely the wrong way?
Thanks in advance!
What I would do is add one last step to the package to write the value of the variable to a table.
Then you can retrieve the value from the table via SQL.
You can either truncate the table every time, or keep a permanent history associated with each time the package runs.

pass a column value to ssis variable

I have a job that I want to run that passes a variable to an ssis package. The variable is a filename but the filename changes daily. I have an access front end that the user enters the filename into. The access program runs a stored procedure which writes the filename to a temp table and then runs the job. I would like the job to query that table for the filename and pass it along to my package variable.
I can get the job to work using a static filename. On the set values tab I used the property path \Package.Variables[User::FileName] and the value \myserver......\filename.txt. But I don't know how to replace that filename with the results of the query
Thanks in advance.
Scott
I may have spoke too soon. The data source saved in my job step was still an value in my package. I had removed the value but didn't re-import the package to SQL. Now that I did that it is not importing anything at all.
I ended up creating an Execute SQL Task in my package that assigns the value in the temp table to my package variable.

sql mvc Calling SSIS packages by searching for a string

I have the user mentioning the filenames from the front end.
At the back end , I have a database , where I have a stored procedure in which I am calling SSIS packages based on the incoming filename.
The problem is I have a number of input files ,
So i don't think I should write
If(file name = x)
call the stored procedure that contains(x)
because there will be too many if-else statements , also I don't know how to count through all the packages.
Is there any other way?
You could have a master package that the stored procedure calls and passes the file name, and have a table that controls what package to call based on the file name. The Master package would use the table to look up the package name and invoke it.

From an SSIS package how should I execute a sql script stored in a table as a varchar(max)?

I'm storing large (varchar(max)) SQL scripts in a table. I'd like to execute the scripts in an SSIS package.
Looking at other posts on this site it's easy enough to get the varchar(max) into an object variable. But then what to do? Is there a way for an Execute Sql Task (SQLSourceType of Variable) to specify an Object variable rather than a String variable?
Is there an approach that will work?
Here's how I might approach it:
Add a Data Flow task to your control flow
Add a Source (ADO.NET) that connects to your database
Create a Package level Object variable (for the next step)
Add a Recordset destination that populates your data into the Object variable created in the previous step
Back on the control flow:
Create a package level String variable for the "current" query (see next step)
Add a For Each ADO.NET enumerator
Connect the previous Data Flow task to the For Each task
Configure the For Each to use the Object variable as a source, and to store the column index with the SQL into the String variable
Add an Execute SQL task inside the For Each task
Configure it to execute a SQL Command from Variable, and pick the string variable containing the current query
Basically it will collect the queries from the table, then for each collected query, assign it to a variable, and then the Execute SQL command can pull the command text from that variable.

How to dynamically set connection string at SSIS?

I have a SSIS-project which uses xml-configuration file (dtsConfig) where the connection string to source data base is given. Configuration file is stored to environmental variable.
Data needs to pulled from four different data bases, i.e. now I need to run the same set of packages four times by using four different connection strings.
I can make four different configuration files where each of them has a different connection string and update it to the environmental variable after each run. This is how I'm doing it now and it works ok, but I wouldn't like to keep on updating the env variable all the time.
Or then I can use the same configuration file and just update the connection string after each run. But I think it's even worse idea than having four different files.
What I would like to do is dynamically change the connection string after each run.
I have a master-package which runs the set of packages I want. So I was thinking of just adding this master package four times in the control flow, after each run I'd need to update the connection string which then would be used at the next run. But how to actually do this?
Or for each loop container which would contain the master package and would loop the it four times and changing the connection string after each iteration would be cool as well.
To run the packages sequentially, you could simply create a table or file with the connection strings (eg. 4 rows for the 4 data sources). You would then have a for each loop which would loop through the connections (from the table or file) and call the child package passing the connection string down to it as a variable. The child package would access the variable through a Package Configuration. The variable in the child package would be pointed to the connection string of the connection.