Assign a Job to a Job Category

This topic describes how to assign Microsoft SQL Server Agent jobs to job categories in SQL Server 2012 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.

In This Topic

  • Before you begin:

    Security

  • To assign a job to a job category, using:

    SQL Server Management Studio

    Transact-SQL

    SQL Server Management Objects

Before You Begin

Security

For detailed information, see Implement SQL Server Agent Security.

Arrow icon used with Back to Top link [Top]

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.

Arrow icon used with Back to Top link [Top]

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).

Arrow icon used with Back to Top link [Top]

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. For more information, see SQL Server Management Objects (SMO).

Arrow icon used with Back to Top link [Top]