共用方式為


設定 SQL Server Agent 作業的排程

適用於:SQL ServerAzure SQL 受控實例

本文說明如何設定 SQL Server Agent 在 SQL Server 或 Azure SQL 受控實例上執行的作業排程。 使用 SQL Server Management Studio (SSMS)、Transact-SQL 或 SQL Server 管理物件 (SMO) 設定 SQL Server Agent 作業排程。

重要

Azure SQL 受控實例上,目前支援大部分但並非所有 SQL Server Agent 功能。 如需詳細資訊,請參閱 與 SQL Server 的 Azure SQL 受控實例 T-SQL 差異。

安全

For detailed information, see Implement SQL Server Agent Security.

先決條件

To configure a schedule for a job, you should have already created a job. 如果您需要建立任務,請參閱 建立任務

設定作業的排程

您可以使用 SQL Server Management Studio (SSMS)、Transact-SQL 或 SQL Server 管理物件 (SMO) 來設定 SQL Agent 作業的排程。

若要在 SQL Server Management Studio 中建立排程,請遵循下列步驟:

  1. 開啟 SQL Server Management Studio (SSMS)。

  2. 在 [物件總管] 中, 連接到一個 SQL Server 的實例,然後展開該實例。

  3. Expand SQL Server Agent, expand Jobs, right-click the job you want to schedule, and select Properties.

  4. Select the Schedules page, and then select New.

  5. 在 [名稱] 方塊中,輸入新排程的名稱。

  6. 若您不想讓排程在建立後立即生效,請清除 [啟用] 複選框。

  7. 針對 [排程類型],選取下列其中一項:

    • Select Start automatically when SQL Server Agent starts to start the job when the SQL Server Agent service is started.

    • Select Start whenever the CPUs become idle to start the job when the CPUs reach an idle condition.

    • Select Recurring if you want a schedule to run repeatedly. To set the recurring schedule, complete the Frequency, Daily Frequency, and Duration groups on the dialog.

    • Select One time if you want the schedule to run only once. To set the One time schedule, complete the One-time occurrence group on the dialog.

若要將排程附加至 SSMS 中的作業,請遵循下列步驟:

  1. 在 [物件總管] 中, 連接到 SQL Server 的實例,然後展開該實例。

  2. 展開 [SQL Server Agent],展開 [作業],右鍵點擊您要排程的作業,然後選取 [屬性]。

  3. Select the Schedules page, and then select Pick.

  4. 選擇您要附加的排程,然後點擊 [確定]

  5. In the Job Properties dialog box, double-click the attached schedule.

  6. 請確認 開始日期 已正確設定。 If it isn't, set the date when you want for the schedule to start, and then select OK.

  7. 在 [作業屬性] 對話框中,選取 [確定]