The following code is seen in several Q&A code snippets here (and elsewhere), I am trying to translate the section N'[Uncategorized (Local)]

    EXEC @ReturnCode = msdb.dbo.sp_add_category @class=N'JOB', 
       @type=N'LOCAL', @name=N'[Uncategorized (Local)]'


I have looked at Microsoft EXECUTE (Transact-SQL)


Is a valid user or login name. name must be a member of the sysadmin fixed server role or exist as a principal in sys.database_principals or sys.server_principals, respectively. name cannot be a built-in account, such as NT AUTHORITY\LocalService, NT AUTHORITY\NetworkService, or NT AUTHORITY\LocalSystem.


[N] 'command_string'

Is a constant string that contains the command to be passed through to the linked server. If the N is included, the string is interpreted as nvarchar data type.

And I am guessing the section N'[Uncategorized (Local)] goes and gets the name of the sysadmin and passes it to execute the job as the sysadmin, but I am not finding a good reference that indicates how all three segments are working together.


The @name parameter is a parameter of msdb.dbo.sp_add_category and not EXEC.

See the sp_add_category documentation:

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

[Uncategorized (Local)] just indicates a default category when you didn't specify a category on the SQL Agent Job. The leading N just indicates the string is nvarchar and not varchar.

Please read through Organize Jobs to learn more about job categories

The code you are looking at is most likely just a scripted out job. For example when I right-click a random job on the SQL Server I'm looking at and script job as > create > new query editor window this is the result:

IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'[Uncategorized (Local)]' AND category_class=1)
EXEC @ReturnCode = msdb.dbo.sp_add_category @class=N'JOB', @type=N'LOCAL', @name=N'[Uncategorized (Local)]'
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback


EXEC @ReturnCode =  msdb.dbo.sp_add_job @job_name=N'Warmup_SSRS_EP', 
        @category_name=N'[Uncategorized (Local)]', 
        @notify_email_operator_name=N'monitor operator', @job_id = @jobId OUTPUT

Where the creation of the category is just included in the script to make sure it exists because otherwise the following procedures would error out.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.