• Jason- (8/23/2012)


    rmechaber (8/23/2012)

    That code errors out on my trial:

    Msg 536, Level 16, State 5, Line 1

    Invalid length parameter passed to the SUBSTRING function.

    Rich

    I've seen this before. There is a negative value in your duration ( like -954448987) While I don't know what causes this (maybe a SQL Agent bug) it is the reason for failing as the value is more than 6 characters. clear your agent history to get rid of the negative value or add a where clause "WHERE run_duration > 0"

    Good call, that was the issue. Why the Agent log has a negative run duration, I don't know; Googling only turned up more "me, too *shrugs*" posts, without an explanation.

    If anyone here has an answer, that would be nice. The job in question was an Index rebuild subplan in a maintanance plan.

    Rich