SSRS Schedules in an Agent Job - changing the delivery order? - sql-server

We have a large number of reports that are setup as subscriptions linked to a schedule. The schedule is then executed as a step within a SQL Agent Job to make sure the reports are only run when certain other steps are first carried out.
When the reports are run from the SQL Agent, I was wondering if there was a way I could manage the priority of specific reports linked to the schedule so I can control which reports run next?

Related

AD-HOC SQL Server Agent Job

Dynamic creation and deletion of an SQL Agent Job
I have created a stored procedure that creates a number of dynamic agent jobs. The stored procedure creates/runs then deletes an Agent Job perfectly. This does mean that there could be a number of jobs running at once.
This allows me to spawn a number of parallel running jobs, shifting data around rather than doing it sequentially.
At each stage success or failure is logged to a table so at a glance I can see what has failed or completed.
Is the use of spawning multiple Agent jobs from a stored procedure like this practical?
It works well and cuts my load time considerably.

SSMS - SSRS job returns after deletion

we have several SSRS reports that we want to run at night.
Every time we create a subscription, SSRS creates a job with its own schedule and one step in the job
for example:
exec [ReportServer].dbo.AddEvent #EventType='TimedSubscription', #EventData='ffe3a82d-367a-424c-8446-d2da0ce10666'
We have 5 reports. Therefore, there are 5 jobs. Instead of executing every single job, we want to combine all jobs into one. Meaning, one job with 5 steps. Therefore, we copy out the step command of each job (the above 'exec' snippet) and add it as an additional step to the main job.
Once this is done, we delete all 5 SSRS generated jobs.
The problem now is that once we restart the ReportServer services or the actual time of the original subscription schedule hits (default: 2am), all these 5 jobs are shown again in SSMS (SQL Server Management Studio). We can delete them but the next day, they are back again.
Any idea? We never had the problem in SQL 2008 R2 but with only with SQL 2014.

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")...

SQL Server Agent Job monitoring and notification

I want to create a stored procedure/ Job that will monitor all the SQL server Agent job. When any of the SQL Server Agent's jobs fail it will send and email with the job name to the admin.
What is the best way to create such a job that will monitor all jobs.
You can approach this issue in several ways. From top of my head you can use either a SSRS report scheduled for auto delivery. Or a SQL agent job that run periodically.
In both cases the an underlying stored procedure needs to be built that queries sysjobs and related tables in MSDB.

Resources