patternsqlMinor
SQL Server 2012 catalog.executions to sysjobhistory - any way to join them?
Viewed 0 times
2012sqlanywayjoinexecutionssysjobhistorycatalogserverthem
Problem
I have exhausted my resources and can't find a foolproof way to join the ssisdb.catalog tables to the jobs that run them. Trying to write some custom sprocs to monitor my execution times and rows written from the catalog tables, and it would be greatly beneficial to be able to tie them together with the calling job.
I'm trying to find out if there are any tables that can be used to join the catalog.executions table to msdb.sysjobhistory. I need to relate which job called the SSIS package and then use the data in executions for my analysis.
I'm trying to find out if there are any tables that can be used to join the catalog.executions table to msdb.sysjobhistory. I need to relate which job called the SSIS package and then use the data in executions for my analysis.
Solution
Not for any case.
But I have some way:
It is designed for only for the case in the message table sysjobhistory, appears string:
"Execution ID: xxxxxxx".
In the following query, in the last column I extract the ExecutionId.
In the case ExecutionId has a value, it can join:
Note that can also attach these tables:
But I have some way:
It is designed for only for the case in the message table sysjobhistory, appears string:
"Execution ID: xxxxxxx".
In the following query, in the last column I extract the ExecutionId.
In the case ExecutionId has a value, it can join:
SELECT *
FROM (
SELECT
h.step_name,
h.message,
h.run_status,
h.run_date,
h.run_time,
SUBSTRING(h.message, NULLIF(CHARINDEX('Execution ID: ', h.message),0)+14 ,PATINDEX('%[^0-9]%',SUBSTRING(h.message, NULLIF(CHARINDEX('Execution ID: ', h.message),0)+14 ,20))-1) ExecutionId
FROM MSDB.DBO.SYSJOBHISTORY h) history
LEFT JOIN
SSISDB.CATALOG.EXECUTIONS ex on ex.execution_id = history.ExecutionIdNote that can also attach these tables:
LEFT JOIN SSISDB.CATALOG.OPERATION_MESSAGES om on history.ExecutionId = om.operation_id
LEFT JOIN SSISDB.CATALOG.EVENT_MESSAGES em on em.operation_id =history.ExecutionIdCode Snippets
SELECT *
FROM (
SELECT
h.step_name,
h.message,
h.run_status,
h.run_date,
h.run_time,
SUBSTRING(h.message, NULLIF(CHARINDEX('Execution ID: ', h.message),0)+14 ,PATINDEX('%[^0-9]%',SUBSTRING(h.message, NULLIF(CHARINDEX('Execution ID: ', h.message),0)+14 ,20))-1) ExecutionId
FROM MSDB.DBO.SYSJOBHISTORY h) history
LEFT JOIN
SSISDB.CATALOG.EXECUTIONS ex on ex.execution_id = history.ExecutionIdLEFT JOIN SSISDB.CATALOG.OPERATION_MESSAGES om on history.ExecutionId = om.operation_id
LEFT JOIN SSISDB.CATALOG.EVENT_MESSAGES em on em.operation_id =history.ExecutionIdContext
StackExchange Database Administrators Q#39007, answer score: 6
Revisions (0)
No revisions yet.