List the queries running on SQL Server

SQL Server

 

Famous database from Microsoft. Skyvia requires the server to be available from Internet.

A way to list the queries that are currently running on Microsoft SQL Server

Query Text

SELECT
    SP.spid,
    RIGHT(CONVERT(varchar, DATEADD(ms, DATEDIFF(ms, SP.last_batch, GETDATE()), '2000-01-01'), 121), 12) AS last_batch_duration,
    SP.program_name,
    SP.hostname,
    SP.loginame
FROM 
    master.dbo.sysprocesses SP
WHERE 
    SP.hostname is not null AND
    SP.status NOT IN ('background', 'sleeping') AND
    SP.cmd NOT IN ('AWAITING COMMAND', 'MIRROR HANDLER', 'LAZY WRITER', 'CHECKPOINT SLEEP', 'RA MANAGER')
ORDER BY 
    last_batch_duration DESC
  

Open Query