Assign a Job to a Job Category

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 for details.

This topic describes how to assign Microsoft SQL Server Agent jobs to job categories in SQL Server by using SQL Server Management Studio, Transact-SQL or SQL Server Management Objects.

Job categories help you organize your jobs for easy filtering and grouping. For example, you can organize all your database backup jobs in the Database Maintenance category. You can assign jobs to built-in job categories, or you can create a user-defined job category and then assign jobs to that.

Before You Begin

Security

For detailed information, see Implement SQL Server Agent Security.

Using SQL Server Management Studio

To assign a job to a job category

  1. In Object Explorer, click the plus sign to expand the server where you want to assign a job to a job category.

  2. Click the plus sign to expand SQL Server Agent.

  3. Click the plus sign to expand the Jobs folder.

  4. Right-click the job you want to edit and select Properties.

  5. In the Job Properties -job_name dialog box, in the Category list, select the job category you want to assign to the job.

  6. Click OK.

Using Transact-SQL

To assign a job to a job category

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

  2. On the Standard bar, click New Query.

  3. Copy and paste the following example into the query window and click Execute.

    -- adding a new job category to the "NightlyBackups" job  
    USE msdb ;  
    GO  
    EXEC dbo.sp_update_job  
        @job_name = N'NightlyBackups',  
        @category_name = N'[Uncategorized (Local)]';  
    GO  
    

For more information, see sp_update_job (Transact-SQL).

Using SQL Server Management Objects

To assign a job to a job category

Use the JobCategory class by using a programming language that you choose, such as Visual Basic, Visual C#, or PowerShell.