Run a specific SSIS Data Flow Task in a Job - ssis

It is possible to run only a specific Data Flow task via Visual Studio (right click on the Data Flow and execute). E.g. you have multiple data flows- but only execute one of them.
I am now trying to implement this ability via a job
- e.g. I have 1 Control Flow with 2 Data Flows (DataFlow1, DataFlow2) -
and in
SQLJob1 - it will fire DataFlow1,
SQLJob2 - will fire DataFlow2 of the same SSISPackage
The aforementioned link states "You can build a special control flow logic using expressions on precendance constraints to define optional execution paths."
I dont want to create special control flow logic - or have 2 separate SSIS packages installed - what would the SQL command be in the Job to fire
only DataFlow1 please?
I see I can in VS right click and disable a specific data flow - and then run the package. I tried to see the command for disabling/enabling a specific data flow, but there is no SQL Query for it - or is it possible to run SQL query to disable/enable specific data flow?

This is the SSIS-way to do this, and I'm sorry, but it involves "special control flow logic" because there is no other way:
Add a package-level variable in your SSIS package.
Add a script task to the control flow of your SSIS package. The script doesn't have to do anything. Think of it as a "starting anchor". It will be the first thing that executes in your package.
Add separate precedence constraints (the little arrows that link tasks) from the script task to your two dataflows.
Double-click on each precedence constraint and set them to use an expression for validation. Use the variable you created, and set one of the paths to be true if the variable is set to "DataFlowA" and the other if it is set to "DataFlowB".
In the jobs, set the value of the variable to the appropriate value for the dataflow you want to have execute.
This is the answer. I'm sorry it's not what you were hoping for but the answer to these questions:
what would the SQL command be in the Job to fire only DataFlow1
please?
is it possible to run SQL query to disable/enable specific
data flow?
Are, respectively,
There is no such command.
No, it is not possible to programmatically enable and disable tasks.

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 Passing Parameters from Master Package to Child to Data Flow Task

I have been working with a co-worker in an attempt to setup a master and sub SSIS package templates. These templates look into an audit table in order to identify the correct batch or create a new one. The start and end times of the batch are passed into the CDC (change data capture) table valued functions which returns the Start and END LSN's of the table.
This works by identifying the start and end dates of the batch in the master package. These dates then get set to user variables in the master package. The master package then calls a sub package and passes the user variable start time as well as user variable end time to the sub packages package level parameters. At this point I can print or write the dates to a random table from the sub package and they are showing the correct values.
Next I want to add a data flow task that will use the sub packages package level parameters (Passed from master package) to run the table valued function for the correct time period. This should return the Start & End LSN's that can be used in the source query. Unfortunately what I am seeing is the Data Flow Task never executes any of the task inside the Data Flow. The Data Flow Task gets a nice green checkmark but if you open the dataflow none of the tasks have been executed.
We are scratching our heads on this one and have even created a simple proof of concept that passes a value from a master package to the sub and then attempts to print it from the sub packages DFT but it never executes.
Any ides what could be causing the data flow to be ignored but yet show a success status?
After a lot of headache and frustration I finally found the answer, or rather my co-worker. In the past I have always created stand alone packages that get called from a job in SSMS. When developing individual packages I typically add either a Data Conversion or Derived Column component at the end of the last step completed in the Data Flow. I then setup a data viewer on the path to the Data Conversion/Derived Column. This allows me to check the data before moving on to the next piece of the data flow.
I was using this tactic when working with a master package that calls the child package I was working on. This was the source of the problem. When the master package calls the child package it identifies that components in the Data Flow are not used later in the package and skips them.
To summarize: If you are using a master package to call a child package make sure all pieces of the Data Flow are used later on in the package or they will be skipped during processing.

Task Execution Working Correctly. Package Execution Not Working Correctly

I have created an SSIS solution (using SQL SERVER 2012) to extract data from ServiceNow. All the tasks are wrapped in a Sequence Container. When I right click on the Sequence Container and click Execute Task the package behaves as expected. It extracts the data from ServiceNow and performs the rest of the etl. However when I click Execute Package from the Solution Explorer the package successfully completes but it does not extract any data from Service Now.
I have played around with settings and different package designs but with no change in behavior. I can execute with true success at the task level but not the package level. This behavior is even apparent after deployment. I can execute with success from the SSISDB but with no data extraction. When I hook the deployed package to a job I still get no data extraction.
My thinking it has to be some kind of bug or hidden proxy setting because I only get true success (with data extraction) when I manually execute at the task level - i.e. the Sequence Container.
I have been using SSIS for a couple years now and have not come across this issue. Hopefully someone can help or have some ideas.
Got it. I needed a break and to think about this clearly. I needed to update the Package Property Delay Validation from False to True. That solved the issue. I guess the SSIS engine needed the extra time to validate the variable and expressions set up within the package.

Check Points in SSIS

I got question from interview!!!
How to achieve Check point functionality in SSIS with out using check point.
If package fails it has to be re-run from the point that it failed instead of rerunning the entire package.without using check point.
one way is create a task dispatcher as entry point in the control flow. This will only keep track of the last task successfully executed and call the next task depending on that persisted variable. The first time it runs the variable would be 0 and therefore it will start in the first task, if the first task completes successfully the variable will be set to 1. If the task 2 fails, then the next time the control flows run it will restart on task1 and so on... the control flow will look like this:

How can a step in an SSIS package check for the time?

The starting item in my Control Flow needs to be something that will check what time it is and set a variable. Is there an item in the Control flow items that can do this?
Access your system variables. System::StartTime will be when the package started execution. If there is a significant amount of time between start of execution and the element that needs to evaluate the current time, you can look at the ContainerStartTime. If that isn't precise enough for you, look at using a script task.
SQL Server 2005 Run a stored procedure via SSIS using GETDATE() as a Parameter