Skip to content

Latest commit

 

History

History
104 lines (75 loc) · 3.08 KB

sp-add-category-transact-sql.md

File metadata and controls

104 lines (75 loc) · 3.08 KB
title description author ms.author ms.reviewer ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs
sp_add_category (Transact-SQL)
Adds the specified category of jobs, alerts, or operators to the server.
MashaMSFT
mathoma
randolphwest
08/21/2024
sql
system-objects
reference
sp_add_category
sp_add_category_TSQL
sp_add_category
TSQL

sp_add_category (Transact-SQL)

[!INCLUDE SQL Server - ASDBMI]

Adds the specified category of jobs, alerts, or operators to the server. For alternative method, see Create a Job Category.

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

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.

Syntax

sp_add_category
     [ [ @class = ] 'class' ]
     [ , [ @type = ] 'type' ]
     [ , [ @name = ] 'name' ]
[ ; ]

Arguments

[ @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 set

None.

Remarks

sp_add_category must be run from the msdb database.

Permissions

[!INCLUDE msdb-execute-permissions]

Examples

The following example 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

Related content