Create a Job Category

This topic describes how to create a job category in SQL Server 2012 by using SQL Server Management Studio, Transact-SQL or SQL Server Management Objects.

SQL Server Agent provides built-in job categories that you can assign jobs to, or you can create a job category and assign jobs to it. 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 also create your own job categories.

In This Topic

  • Before you begin:

    Limitations and Restrictions

    Security

  • To create a job category, using:

    SQL Server Management Studio

    Transact-SQL

    SQL Server Management Objects

Before You Begin

Limitations and Restrictions

Multiserver categories exist only on a master server. There is only one default job category available on a master server: [Uncategorized (Multi-Server)]. When a multiserver job is downloaded, its category is changed to Jobs From MSX at the target server.

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 create a job category

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

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

  3. Right-click the Jobs folder and select Manage Job Categories.

  4. In the Manage Job Categories server_name dialog box, click Add.

  5. In the new dialog box, in the Name box, enter a name for the new job category.

  6. Select the Show all jobs check box. Select one or more jobs for the new category by checking the boxes corresponding to the jobs.

  7. Click OK.

  8. In the Manage Job Categories server_name dialog box, click Refresh to ensure that the new job category is active. If everything looks as expected, close this dialog box.

For more information on these dialog boxes, see Job Categories / Manage Job Categories and Job Categories Properties / New Job Category.

Arrow icon used with Back to Top link [Top]

Using Transact-SQL

To create 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.

    -- creates a local job category named AdminJobs 
    USE msdb ;
    GO
    EXEC dbo.sp_add_category
        @class=N'JOB',
        @type=N'LOCAL',
        @name=N'AdminJobs' ;
    GO
    

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

Arrow icon used with Back to Top link [Top]

Using SQL Server Management Objects

To create a job category

Call 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). For example code, see Scheduling Automatic Administrative Tasks in SQL Server Agent.

Arrow icon used with Back to Top link [Top]