[Thursday, January 05, 2012]
I recently upgraded to SQL Server 2008 R2 and started getting a 'string or binary data would be truncated' error when I try to view the history for a job via SQL Server Management Studio. Here's a way to grab the history manually. Without errors.
USE msdb
DECLARE @jobname VARCHAR(250)
SET @jobname = 'JOB NAME GOES HERE'
SELECT sj.name, sj.description, sjh.step_id, sjh.step_name, sjh.message,
sjh.run_status, sjh.run_date, sjh.run_time, sjh.run_duration, sjh.server
FROM sysjobhistory AS sjh
LEFT OUTER JOIN sysjobs AS sj ON sjh.job_id = sj.job_id
WHERE sj.name = @jobname
ORDER BY sjh.run_date DESC, sjh.run_time DESC
Posted by: Benjamin Felt
