sp_add_category (Transact-SQL)

Applies to: SQL Server (all supported versions) Azure SQL Managed Instance

Adds the specified category of jobs, alerts, or operators to the server. For alternative method, see Create Job Category using SQL Server Management Studio.

Topic link icon Transact-SQL Syntax Conventions


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.


     [ [ @class = ] 'class', ]   
     [ [ @type = ] 'type', ]   
     { [ @name = ] 'name' }  


[ @class = ] 'class' The class of the category to be added. class is varchar(8) with a default value of JOB, and can be one of these values.

Value Description
JOB Adds a job category.
ALERT Adds an alert category.
OPERATOR Adds an operator category.

[ @type = ] 'type' The type of category to be added. type is varchar(12), with a default value of LOCAL, and can be one of these values.

Value Description
LOCAL A local job category.
MULTI-SERVER A multiserver job category.
NONE A category for a class other than JOB**.**

[ @name = ] 'name' The name of the category to be added. The name must be unique within the specified class. name is sysname, with no default.

Return Code Values

0 (success) or 1 (failure)

Result Sets



sp_add_category must be run from the msdb database.


Only members of the sysadmin fixed server role can execute sp_add_category.


The following example creates a local job category named AdminJobs.

USE msdb ;  
EXEC dbo.sp_add_category  
    @name=N'AdminJobs' ;  

See Also

sp_delete_category (Transact-SQL)
sp_help_category (Transact-SQL)
sp_update_category (Transact-SQL)
dbo.sysjobs (Transact-SQL)
dbo.sysjobservers (Transact-SQL)
System Stored Procedures (Transact-SQL)