Just tried running it on SQL Server 2005 and got this error:
Msg 1001, Level 15, State 1, Line 77
Line 77: Length or precision specification 0 is invalid.
With this line highlighted:
,CAST(STUFF(STUFF(REPLACE(STR(run_duration, 6), ' ', '0'), 3, 0, ':'), 6, 0, ':') AS time(0)) AS Duration
It doesn't like "time(0)"