Edit

Share via


Create a schedule

Applies to: SQL Server Azure SQL Managed Instance

Important

On Azure SQL Managed Instance, most, but not all SQL Server Agent features are currently supported. See Azure SQL Managed Instance T-SQL differences from SQL Server or SQL Agent job limitations in SQL Managed Instance for details.

You can create a schedule for SQL Server Agent jobs in SQL Server by using SQL Server Management Studio, Transact-SQL, or SQL Server Management Objects.

Security

For detailed information, see Implement SQL Server Agent security.

Use SQL Server Management Studio

  1. In Object Explorer, connect to an instance of the SQL Server Database Engine, and then expand that instance.

  2. Expand SQL Server Agent, right-click Jobs, and select Manage Schedules.

  3. In the Manage Schedules dialog box, select New.

  4. In the Name box, type a name for the new schedule.

  5. If you don't want the schedule to take effect immediately after it has been created, clear the Enabled check box.

  6. For Schedule Type, select one of the following:

    • To start the job when the CPUs reach an idle condition, select Start whenever the CPUs become idle.

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

    • If you want the schedule to run only one time, select One time. To set the One time schedule, complete the One-time occurrence group on the dialog box.

Use Transact-SQL

  1. In Object Explorer, connect to an instance of Database Engine.

  2. On the Standard bar, select New Query.

  3. Copy and paste the following example into the query window and select Execute. This example creates a schedule named RunOnce. The schedule runs one time, at 23:30 on the day that the schedule is created.

    USE msdb;
    GO
    
    EXECUTE dbo.sp_add_schedule
        @schedule_name = N'RunOnce',
        @freq_type = 1,
        @active_start_time = 233000;
    GO
    

For more information, see sp_add_schedule.

Use SQL Server Management Objects

Use the JobSchedule class by using a programming language that you choose, such as Visual Basic, Visual C#, or PowerShell. For more information, see SQL Server Management Objects (SMO).