Search code examples
sql-serverservicemaintenance-plan

SQL Server: Programmatically Execute Maintenance Plan


Is there any way to programmatically execute (start) a SQL Server maintenance plan? We have a windows service that runs nightly and updates the DB with lots of data, once that is finished we would like to trigger a maintenance plan in the DB to start running.


Solution

  • You can start a job which is part of your maintenance plan by sp_start_job:

    use msdb; 
    go
    exec dbo.sp_start_job N'job_name' ;
    go