I am trying to run the following query from a database monitor item in Zabbix. The query returns the last run date of the specified job as a unix timestamp. The database monitor item keeps becoming unsupported with the following error "cannot fetch row:[SQL_ERROR]:[22003][0][[Microsoft][ODBC Driver 13 for SQL Server]Numeric value out of ]|". I can run the query via isql using the same DSN and login information so I'm not sure what the issue could be. My Zabbix server version is 3.2.
Code:
SELECT DATEDIFF(s,'1970-01-01 00:00:00', MAX(CAST( STUFF(STUFF(CAST(jh.run_date as varchar),7,0,'-'),5,0,'-') + ' ' + STUFF(STUFF(REPLACE(STR(jh.run_time,6,0),' ','0'),5,0,':'),3,0,':') as datetime))) FROM msdb.dbo.sysjobs j INNER JOIN msdb.dbo.sysjobhistory jh ON jh.job_id = j.job_id AND jh.step_id = 0 WHERE j.[name] = 'Job Name'
Comment