Parallel ssis execution - ssis

I have about 112 packages. Actually these packages are executing sequentially using package master.
I need to execute these packages parallel. I create package master and add all these packages manually but it's not easy for support and maintenance. Is there a way or an idea how to extract all packages names from table parameter for example, then execute them in parallel automatically and not add packages manually?

You can run an execute SQL in a foreach loop (in SSIS) or you can run in a CURSOR in SSMS.
This is a assuming you deploy to SSISDB.
BEGIN
DECLARE #execution_id BIGINT
EXEC [SSISDB].[catalog].[create_execution]
#package_name=N'[Package Name].dtsx'
, #project_name=N'[ProjectName]'
, #folder_name=N'[FolderName]'
, #use32bitruntime=False
, #reference_id=NULL
, #execution_id=#execution_id OUTPUT
-- Execute the package
EXEC [SSISDB].[catalog].[start_execution] #execution_id
END
You can also add parameters if needed.
This is a good article about different applications: https://www.timmitchell.net/post/2016/11/28/a-better-way-to-execute-ssis-packages-with-t-sql/
Note: The default is run async

SSIS does not have support for such scenario out of the box. There are some approaches to do this, but with some limitations.
Async Out of main process Execution
The approach described in #KeithL's answer is pretty straightforward, but has certain drawbacks:
Each child package started in its own execution. You can end up having started all 112 packages experiencing resource shortage. SSIS Engine does not orchestrate overall resources in this case.
Package started in its own execution. It does not inherit parent package params or connection managers. You have to set it anew from calling SQL code or environment variable mappings.
From support point of view - you get 113 independent executions in the SSIS log. Not easy to link it especially on high-load system.
In-process execution
Alternative - handle this parallel invocation scenario with SSIS Task Package Run. From SSIS design approach, you have to describe all packages being run in the master package. Constructing the master package by hand is not practical, so you can use BIML. BIML can build your master package based on some metadata; it is really powerful but requires learning and practice.
Limited parallel execution
Create a For Loop block in SSIS with control variable i and loop exist condition i==0. In the block - set i = select count(*) from <package_queue> with (updlock, readpast) with SQL Task and process to dummy Expression Task if i==0; this is a loop break path. Otherwise, with path condition i>0 read one line from the package queue removing if from the queue, and start selected package execution with Package Run task.
Quite complex, but this is not the end of the story. Make several copies of the Copy Loop block in the SSIS Master package. Thus you will get a framework for concurrent execution with limited concurrency.

Related

Sequencing of task using SSIS

I am trying to implement logging in my SSIS package. I would like to start logging by writing a message- Batch started -- to my custom log table. I am currently having the following tasks created which run in parallel. I am thinking of creating a execute sql task which will log that. How do I tell SSIS to execute sql task before executing the other tasks in the package. Do I need to move all these tasks in a sequence container.
Please find the screenshot of my package.
The best way I feel to implement logging is to have it in a non-intrusive manner i.e. to have them run in the background. SSIS provides this facility via 'Event Handlers'.
Open your package and go to 'Event Handlers'. With 'Executable' set as "Your Package Name", select 'OnPreExecute' as 'Event handler'. You then click on the hyperlink for you to proceed with adding the 'Execute SQL Task' for auditing.
Using the same above, you can then go on to add 'OnPostExecute'. Additionally this technique can be implemented across individual task level as well.
For more information you can refer to - https://learn.microsoft.com/en-us/sql/integration-services/integration-services-ssis-event-handlers

SSIS Always run a specific step last without connecting to every parent

I have an SSIS package with about 50 different steps. Many of the steps will run in parallel.
I would like to put a ScriptTask at the end of the package such that, regardless of success or failure, I send out an email which reports on the status of the package run (the package logs things to a database as it runs, so the ScriptTask involves querying the status tables and formatting them into HTML).
Is there a way to have a task that executes when all other tasks have either completed running, or been skipped due to dependencies?
I have tried to add my task to the OnError event handler, but this has it raise up to n times when tasks fail in parallel. I don't want to have every single step flow to the ScriptTask with the OnFailure condition, because it will make the package functionally impossible to use due to the volume of connections. I also believe that connecting it as such would not ensure it ran, as some steps would be skipped and thus not have a success or failure status.
I can do this in two different ways
Add a Sequence Container to your Control Flow.
Move all existing Tasks inside of the the Sequence Container
Add your Script Task outside the Sequence Container. Change the Precedence constraint from Success to Completion by double clicking on the line
Option b
Create an package that has your script task in it.
Create a master package that runs the original package and then calls the package with the script task, passing any variables as needed for it to generate the email.

File Watcher Job Using SSIS

I am using SSIS for ETL and I need to monitor a source folder for the source file to be arrived. When ever a file arrives I need to move that file into another location and rename the file and start executing another SSIS Package. Here we don't have an option to use use any other tool to automate the execution. We have only choice to use SQL Server, SSIS.
I need the mechanism and the logic to implement this logic.
I'm assuming that by "File Watcher" you don't mean FileSystemWatcher class in .NET, as there wouldn't be any point in using this class if you're limited to SQL Server and SSIS (you'd need a job with forever-running SSIS package containing ScriptTask with FileSystemWatcher).
The only solution is to create two-step job. First step would contain SSIS package for reading directory content and comparing it to files history log. Second step would contain your main package and would execute only if first steps succeeds or returns value indicating that there are new files to process.
Your answer is here and here. My personal favorite way of doing it is having an infinite loop package. Yet another way of doing it would be to encapsulate the entire logic in an SSIS package and fire it every X minutes. Vary the value of X depending on the urgency.

parent package in SSIS

I need to execute 29 ssis packages. So planning to create one master package which will execute all these packages. I don't know how to implement this. Can you please explain in brief. Thanks in Advance !
This article does a pretty good job on giving a high level summary of what a master package does, which is basically a package executing other packages in the control flow: http://dichotic.wordpress.com/2006/10/30/creating-the-master-package/
This article goes over logging, variable scope, transactions, etc. from a fairly high level : http://74.125.95.132/search?q=cache:zMWg5KkFGZcJ:dmachicago.com/WhitePapers/SSIS%2520Master%2520Control%2520Package.doc+ssis+master+package+template&cd=3&hl=en&ct=clnk&gl=us
Alternativly, just use the execute package task. You have to deploy your ssis packages to the server first for this to work.

SSIS 2005/2008 - How do I allow multiple tasks to have a common target task?

In VB pseudocode, I'm trying to accomplish the following using SSIS (either 2008 or 2005)
If FileHasAlreadyBeenDownloaded = False Then
DownloadTheFileFromFTP
End If
ImportTheDownloadedFile
To do this in SSIS I have a script task to check for the file, and if it exists it transfers directly to the DataFlow Task using conditional expressions. If the file doesn't exist, it transfers to the FTP Task, and the FTP Task transfers to the DataFlow Task.
It seems, though, that I can't have two tasks lead into one common shared task, because no matter which path the code takes it won't execute the DataFlow Task. If I make a copy of the DataFlow task and have each path go to its own Task, then all works perfectly.
Is this a documented thing with SSMS that I just haven't found? I looked through 31 pages of questions on SSMS before posting, so hopefully this isn't a stupid question.
I also tried using Expressions on the FTP task to set "Disabled=#FileAlreadyDownloaded=True" but that works only in SSMS 2008 and didn't seem to work in SSMS 2005.
Thanks so much for any pointers on this!
It might be worth trying putting the script task and the FTP task inside a container task, and link the the container to the data flow task on success.