Please find updated script for SQL Server 2005\2008
declare @spid int
declare @blocked int
declare @db_name varchar(500)
declare @program_name varchar(1000)
declare @loginame varchar(500)
declare @login_time datetime
declare @last_batch datetime
declare @STR varchar(100)
declare @runtimeinmin int
declare