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)]'
Examples
I have looked at Microsoft EXECUTE (Transact-SQL)
'name'
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.
and
[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.
Best Answer
The @name parameter is a parameter of
msdb.dbo.sp_add_category
and notEXEC
.See the sp_add_category documentation:
[Uncategorized (Local)]
just indicates a default category when you didn't specify a category on the SQL Agent Job. The leadingN
just indicates the string isnvarchar
and notvarchar
.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: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.