syg_hira's tech-work memo

某人材サービス会社の情報共有インフラ担当のおぼえがきです。MicrosoftのEnterprise製品多め。

Run SQL Server Maintenance Plan from command line (Updated)

You can run "SQL Server Maintenance Plan" with DTExec.exe.

When you create maintenance plan, the "Job" is created in SQL Server by SQL Server Management Studio automatically.

The "Job" has the "Step", the "Step" has command line property. You can use the same property as the command line option from "Step" and provide to DTExec.exe.

1.Create Maintenance Plan on SQL Server Management Studio.
2.Open Job.
-SQL Server Agent-Job...
If you set the name as "Daily Backup" for the plan, the job name may be "Daily Backup.Subplan_1"
3.Click "Step", select a step and "Edit", Click "Command line" tab.
4.Copy command line option string.
5.Provide the option and run DTExec.exe
example

DTExec.exe /SQL "Maintenance Plans\Daily Backup" /SERVER DBSvr  /CHECKPOINTING OFF /SET "\Package\Subplan_1.Disable";false /REPORTING E