I need to run a task to update a table, periodically, using a stored procedure. Could you let me know if it is possible to schedule periodic tasks and to run any system command within stored procedure?
You can use SQL Server Agent to create jobs that run at regularly-scheduled intervals. One of the job step types is executing a stored procedure.
I use a 3rd party tool for my schedules. To be honest, it's not a great deal better than Sql Server Agent, but there are few perks to it. It's called
System Scheduler.
Related
I have two SSIS ETL packages that I need to schedule to run on a daily basis. The two packages load data into two different staging databases so these can be run in parallel. However, at the end of execution of both the jobs, I need to call a separate job (stored procs) to load data into final database from the staging database.
Does SQL Server Job Scheduling Agent provide any features for tracking if the previous two jobs were completed successfully or not?
Any help is highly appreciated.
Thanks!
Your best bet is to Wrap your 2 SSIS packages in a Master Package - These can be run in parallel within this.
Then create a Job with this as step 1
Step 2 can be Exec sp_run_job [job you need to run]
I would recommend that you include a third 'control' package in your ssis project that contains Execute Package tasks to run the two packages in parallel within a Sequence Container, and then an Execute SQL task following the successful completion of the Sequence Container to kick off the stored procedure once these both complete.
Doing this, you only need to have one Agent job that runs the 'control' package.
Is it possible in SQL Server to run several jobs simultaneously under different sessions under same job.
For example, I have N stored procedures to run. They all have to be run under different sessions and start at the same time. I don't want to create N jobs, I want all of them start at the same time under 1 job.
In the past I've had one job create and start several other jobs using the sp_add_job command. If you set the delete level to 3 then the job will then get automatically deleted once it has completed.
The disadvantages are security and monitoring all the jobs.
I don't see any other option than using ssis sql script tasks for different scripts without any link between them and executing them. This will allow to run different SP or sql script to run parallel.Thanks!
I would like to run a procedure in MSSQL based on result of some step in other job.
What I want to achieve:
I want to run a specific procedure after LOAD of data. I dont want to set job start time only at specific time but I want to condition run also on success of other step in other job. But I want tu run a job only if some step in other job was successful. And I want to run it at specific time.
The catch is that this procedure is in other JOB. These two procedures are not in the same JOB.
Is it possible to make a condition like this?
Thank you.
Currently running SQL 2005 on Server 2005. I have a TSQL script which updates 1000 rows at a time. It loops through a counter until there are no rows to update.
In my situation, I have a lot of rows to update and I need to run this "after hours". So I would like to see if there is a way that I can schedule a way to automatically start and stop a task based upon a set time. I am thinking that I could place this task in a SP and start it with SQL Agent. However, I can not think of how to stop the task automatically. I'm open to SSIS too.
You can use a SQL Job, and make this call a stored procedure or some sql. The job can be set on a timer, for specific days etc.
See Creating a Job for help
You can schedule following T-SQL to stop jab as well.
USE msdb ;
GO
EXEC dbo.sp_stop_job N'Your job name' ;
http://technet.microsoft.com/en-us/library/ms182793.aspx
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?