SSIS Job run in loop - sql-server

I have an SSIS job which pulls data from one database and pushes into another. Currently the actions are triggered when a record is inserted into a table.
My understanding is using a SQL Server trigger to launch an SSIS Job is not advised. Suggesting to me the preferred route for this use case is to use a recurring schedule.
If I schedule every 10 seconds, will the ETL job launch again if the previous run has not finished? (Is there a better word to describe this behavior in the computing spacing?) If the job relaunches, is there a preferred way to accomplish this behavior?

If I schedule every 10 seconds, will the ETL job launch again if the previous run has not finished?
No. The next run time is computed once the job finishes, based on the "Starting at" and the next interval that meets the cycle interval.
While it is running the "Start Job at Step" option on the SQL Server Management Studio interface will be grayed out.
If you try to kick off the job again forcefully using sp_start_job, you'll get a error message saying it's already running.

Related

trigger SSRS report when finishing a SSIS job

A number of SSIS packages have been deployed to the SSI-catalog and are scheduled through SQL Agent jobs.
On the SSRS-server I have created a report that gives me insight in the executions of all SSIS-packages run on the SSIS-server.
I have created a job (Send me report) that, when executed, sends me this report.
I know how to create a jobstep that fires this SQL Agent Job.
I add this jobstep to all the jobs that execute SSIS packages.
However, I am not the only one scheduling packages and not all of my colleagues add this jobstep. The jobs are scheduled and created irregularly. So sending the report every day would be nonsense because sometimes the jobs don't run for a month. Other times, 5 jobs a day are executed.
Is there a way to trigger the job 'Send me report' whenever a SSIS-package finishes running? Regardless of how it was started? Regardless of what the outcome was?
Create a data driven subscription to the report that execute a stored procedure that check if any jobs was executed the day (probably the previous day or running 24 hours, etc.)

How do you run SQL Server Merge Replication Jobs sequentially?

I work with an environment that uses Merge Replication to publish a dozen publications to 6 a dozen subscribers every 10 minutes. When certain jobs are running simultaneously, deadlocks and blocking is encountered and the replication process is not efficient.
I want to create a SQL Server Agent Job that runs a group of Merge Replication Jobs in a particular order waiting for one to finish before the next starts.
I created an SSIS package that started the jobs in sequence, but it uses sp_start_job and when run it immediately starts all the jobs so they are running together again.
A side purpose is to be able to disable replication to a particular server instead of individually disabling a dozen jobs or temporarily disabling replication completely to avoid 70+ individual disablings.
Right now, if I disable a Merge Replication job, the SSIS package will still start and run it anyway.
I have now tried creating an SSIS package for each Replication Job and then creating a SQL Server Agent job that calls these packages in sequence. That job takes 8 seconds to finish while the individual packages it is calling (starting a replication job) takes at least a minute to finish. In other words, that doesn't work either.
The SQL Server Agent knows when a Replication job finishes! Why doesn't an SSIS package or job step know? What is the point of having a control flow if it doesn't work?
Inserting waits is useless. the individual jobs can take anywhere from 1 second to an hour depending on what needs replicating.
May be I didn't see real problem but it is naturally that you need synchronization point and there are many ways to create it.
For example you could still run jobs simultaneously but let first job lock a resource that is needed for second, that will wait till resource will be unlocked. Or second job can listen log table in loop (with wait for a "minute" and self cancel after "an hour")...

Can I get SQL Server to reset a job if the job takes more time than the prescribed interval on a specific job execution?

I have a job that runs every 5 minutes. Every once in a while, if our database load is large, the job will take longer than that. The job will then no longer run, because the next scheduled time is in the past. Is there a way I can get SQL Server to work around this so that it runs again even after one of these long runs?
If you were to have a script that runs continuously, you can spawn a second script from within the script every 5 minutes (without waiting for it to exit). There are many alternative (better) ways to do scheduling in Windows involving custom applications.
But then you will have overlapping script runs if one goes beyond it's 5 minutes, which is probably not what you want. A workaround is to create a temp file when the second script starts and delete it when it's done, and check for its existence in the beginning of the script, if it exists, you exit.

schedule sql job in another server via stored procedure

Here is a picture of how things are supposed to work.
I'll log into sql server and manually start jobA. My interaction ends here. This job doesn't have a schedule enabled. Hence it is manually started. It has 3 steps. The 3rd step will execute another job manually (which is on another server). Technically the 3 step should in turn schedule jobA, to run say after 5 minutes (only 1 time).
But how to schedule jobA which is on another server?
Maybe it is better for jobB to wait for 5 minutes and then start jobA (without scheduling).
Assuming it is SQL Server 2005 or newer, You can use WAITFOR:
WAITFOR DELAY '00:05';
Or if You insist on scheduling a job using stored procedure, check sp_add_schedule stored procedure.
If You already knew this and focus of your question is on 'another' server, check: How to run a Job from a Stored Procedure in another server?

Execute long running jobs in SQL Server

I am working with SQL Server 2008. Using the Agent, I have created a job and scheduled it to execute every minute.
The job executes a stored procedure that moves data from table XXX, to a temp table, and then eventually into table YYY.
The execution of the job may take more than one minute - since the data is rather large.
Will a second instance of the job be started even though the first instance is still running?
If so, should I mark records in temp table (status = 1) to indicate that those records are being processed by a previous instance of the job?
Is there a way for me to check that an instance of the job is currently running, so that I don't initiate a second instance of the job?
Is there another solution for this that I am unaware of? (throughput is important)
Only one instance of a particular job can run at any one time.
So there is no need to take any particular precautions against another execution of the same job beginning before the first one has stopped.
check this post
How to Prevent Sql Server Jobs to Run simultaneously
How to Prevent Sql Server Jobs to Run simultaneously
As Well HERE
Running Jobs
http://technet.microsoft.com/en-us/library/aa213815(v=sql.80).aspx
If a job has started according to its schedule, you cannot start another instance of that job on the same server until the scheduled job has completed. In multiserver environments, every target server can run one instance of the same job simultaneously.

Resources