How to find Job Name from Job ID in MSDB?
While you to some investigation using SQL Server log or trace output, you may notice that you will get Job ID (A long big value like 9BF2B9D2-38F4-4F84-A999-64ADBC31DCC0) instead of job name in output. This long value rarely helps you to understand the actual job name in SQL Agent.
Use below query to identify the actual job name from job id:
SELECT *
FROM msdb.dbo.sysjobs
WHERE job_id = CAST( JOB_ID AS UNIQUEIDENTIFIER)
Example:
If your trace output is below:
EXECUTE msdb.dbo.sp_sqlagent_log_jobhistory @job_id = 0xEE3F000650732D4DB127DF7C7F95ED44, @step_id = 2, @sql_message_id = 15457, @sql_severity = 0, @run_status = 1, @run_date = 20100909, @run_time = 113501, @run_duration = 0, @operator_id_emailed = 0, @operator_id_netsent = 0, @operator_id_paged = 0, @retries_attempted = 0, @session_id = 180, @message = N'Executed as user: MPFA\GRR_SERVER_ADMIN. Configuration option ''Agent XPs'' changed from 1 to 1. Run the RECONFIGURE statement to install. [SQLSTATE 01000] (Message 15457). The step succeeded.'
You can find the related job name using the given code as below:
SELECT *
FROM msdb.dbo.sysjobs
WHERE job_id = CAST(0xEE3F000650732D4DB127DF7C7F95ED44 AS UNIQUEIDENTIFIER)
Use below query to identify the actual job name from job id:
SELECT *
FROM msdb.dbo.sysjobs
WHERE job_id = CAST( JOB_ID AS UNIQUEIDENTIFIER)
Example:
If your trace output is below:
EXECUTE msdb.dbo.sp_sqlagent_log_jobhistory @job_id = 0xEE3F000650732D4DB127DF7C7F95ED44, @step_id = 2, @sql_message_id = 15457, @sql_severity = 0, @run_status = 1, @run_date = 20100909, @run_time = 113501, @run_duration = 0, @operator_id_emailed = 0, @operator_id_netsent = 0, @operator_id_paged = 0, @retries_attempted = 0, @session_id = 180, @message = N'Executed as user: MPFA\GRR_SERVER_ADMIN. Configuration option ''Agent XPs'' changed from 1 to 1. Run the RECONFIGURE statement to install. [SQLSTATE 01000] (Message 15457). The step succeeded.'
You can find the related job name using the given code as below:
SELECT *
FROM msdb.dbo.sysjobs
WHERE job_id = CAST(0xEE3F000650732D4DB127DF7C7F95ED44 AS UNIQUEIDENTIFIER)
Comments