View current sql queries on MSSQL database

To view current sql queries running on sql database you can use this sql script to get current query and elapsed time.

SELECT sqltext.TEXT,
req.session_id,
req.status,
req.command,
req.cpu_time,
req.total_elapsed_time
FROM sys.dm_exec_requests req
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext

I have only tested the script Microsoft SQL Server 2012 and therefore I’m not sure if it’s working on MySQL.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.