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.
Related
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?
I'm working with SSIS and am needing to read all the Customer Numbers out of the Customer table, and search through a directory to see if a PDF file exists with the Customer Number (e.g. A000134) within the filename. If it does, attach it to an email and send.
Does anyone have any suggestions on how this could be achieved?
How I thought of approaching it was:
1) Loop through the directory and get all the filenames/path and write to a table.
2) Using String Functions, pull the Customer Number out of the filename.
3) Call a Stored Procedure and within the stored proc, loop through all customers who have a file to send (joining on Customer Number between CustomerTable and FilesTable), and use #file_attachments in sp_send_dbmail to reference the file name to send.
Nice problem but i think SSIS is not right toll to solve this.
Still you can achieve using ssis
Load file data in TXT column and use full text search and use
full-text-search query in ssis
Use custom code to look into files using (C# or Vb) for ssis
But My suggestion would be write some stand alone utility to do this job done.
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.
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.
I have a table with a column type of xml. I also have a directory that can have 0 to n number of xml documents. For each xml document, i need to insert a new row in the table and throw the xml into the xml column.
To fit with our clients needs, I need to perform this operation using an SSIS package. I plan to use a Stored Procedure to insert the xml, passing in the file path.
I've created the stored procedure and tested, it functions as expected.
My question is, how do I execute the stored procedure from an SSIS package for each xml document is a specific directory?
Thanks in advance for any help.
-
Basically you just need to loop through the files and get the full file paths to pass to the stored proc. This can be done easily using a For Each Loop and the ForEach File Enumerator. This page has a good description of how to set that up:
http://www.sqlis.com/post/Looping-over-files-with-the-Foreach-Loop.aspx
Within the loop then you just access the variable that is populated each time the loop executes (an XML file is found) and send it as a parameter into an Execute SQL Task (residing inside your For Eacu Loop container) to call your stored procedure. Here is an example of passing variables as parameters:
http://geekswithblogs.net/stun/archive/2009/03/05/mapping-stored-procedure-parameters-in-ssis-ole-db-source-editor.aspx
You don't need to use a stored procedure for this. You can do all of this within an SSIS package. Here's how:
Have a For-Each Loop task read all available files in the folder. Put the full path of the file into a variable called XMLFileName
Inside the For-Each loop, use a Data-Flow task read the contents.
The OLE_SRC is reading from the same SQL Server and it's statement is SELECT GetDate() as CurrentDateTime
The DerivedColumn component creates a column called XMLFilePath with the full path of the XML file
The ImportColumn component is the one that does the magic. It will take the XMLFilePath as an input column, give it the LineageId of a new output column you create and it will import the full XML for you. Read more on how to set it up here:
http://www.bimonkey.com/2009/09/the-import-column-transformation/
Use the OleDB Destination to write to the table.