Try this. You may want to add more conditions like last batch time.
declare @spidstr varchar(8000)
select @spidstr=coalesce(@spidstr,'')+'kill '+convert(varchar, spid)+ '; '
from master..sysprocesses WHERE dbid=db_id('master') and open_tran = 0 and status = 'sleeping'
print @spidstr
--EXEC(@spidstr)