Skip to main content
Skip table of contents

Users, Applications and DBs Using SQL Server Now?

To verify who and what applications are hitting which databases on your MS SQL Server now:

  • Open SSMS and connect to the desired SQL instance

  • Right-click the instance name → New Query

  • Copy and paste the code below on the right panel:

SQL
SELECT 
    HostName,
    Loginame,
	Login_Time,
	Program_Name,
    DB_NAME(dbid) [DB_Name],
	right(convert(varchar, 
        dateadd(ms, datediff(ms, last_batch, getdate()), '1900-01-01'), 
        121), 12) as 'Duration',
    CPU as CPU_Time,
    Status,
	Cmd,
	SpID
FROM
    master.dbo.sysprocesses
WHERE
    spid > 50
    AND status not in ('background', 'sleeping')
	-- AND Loginame LIKE '%UserName%'  -- <--- Filter by Username
ORDER BY 
    Duration DESC
  • Click Execute of F5 (multiple times as needed).

Example

Keywords: Query, Queries, Performance, MS SQL Server, Doing Now, Frozen

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.