The JobCategories collection contains Category objects exposing a SQL Server Agent job-organizing method.
For SQL Server Agent, categories offer a mixed system and user-defined method for grouping alerts, operators, and jobs. When using SQL-DMO to administer jobs, a job category can be used to filter job lists used to streamline administrative tasks, such as job execution.
With the JobCategories collection, you can:
For more information about creating a SQL Server Agent job category, see “Category Object.”
To remove a job category
oJobServer.JobCategories.Remove("Northwind_Backup")
Note When using the Remove method of the JobCategories collection, existing SQL Server Agent jobs are reclassified as necessary. If a locally-defined job exhibits the removed category, it is assigned the system-defined category [Uncategorized (Local)] when the existing category is removed. If a job targets multiple TSX servers, it is assigned the system-defined category [Uncategorized (Multi-Server)] when the existing category is removed.
When using the Item or Remove method, the JobCategories collection supports member identification using either name or ordinal reference syntax. For example:
Set oCategory = oJobServer.JobCategories("Northwind_Backup")
Or:
Set oCategory = oJobServer.JobCategories(7)
Add Method | Refresh Method |
Item Method | Remove Method (Collections) |
ItemByID Method |