This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am sharing one script to find bad processes or sessions of Microsoft SQL Server.
Using this script, you can find block process, and which host, application, a user is running with it.
Running this script will tell you which instance of a process is using lots of CPU on the database server. You can use the loginame or hostname columns to identify the person.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
SELECT TOP 25 spid ,blocked ,convert(varchar(10),db_name(dbid)) as DBName ,cpu ,datediff(second,login_time, getdate()) as Secs ,convert(float, cpu / datediff(second,login_time, getdate())) as PScore ,convert(varchar(16), hostname) as Host ,convert(varchar(50), program_name) as Program ,convert(varchar(20), loginame) as Login FROM master..sysprocesses WHERE datediff(second,login_time, getdate()) > 0 and spid > 50 ORDER BY pscore desc |
Leave a Reply