Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 8 down vote accepted

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)
BEGIN
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

END

DECLARE @jobId BINARY(16)
EXEC @ReturnCode =  msdb.dbo.sp_add_job @job_name=N'Warmup_SSRS_EP', 
        @enabled=1, 
        @notify_level_eventlog=0, 
        @notify_level_email=3, 
        @notify_level_netsend=0, 
        @notify_level_page=0, 
        @delete_level=0, 
        @description=N'Warmup_SSRS_EP', 
        @category_name=N'[Uncategorized (Local)]', 
        @owner_login_name=N'domain\user', 
        @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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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