Home > SQL > SQL Server – Find Currently Running Queries

SQL Server – Find Currently Running Queries

http://blog.sqlauthority.com/2009/01/07/sql-server-find-currently-running-query-t-sql/

A customize version from Pinal Dave blog, few more helpful columns added:

  • database name
  • host name
  • program name and
  • login name
    SELECT sqltext.TEXT,
    req.session_id,
    req.status,
    req.command,
    req.cpu_time,
    req.total_elapsed_time,
    DB_NAME(req.database_id) AS database_name,
    ses.host_name, 
    ses.program_name, 
    ses.login_name
    FROM sys.dm_exec_requests req
    INNER JOIN sys.dm_exec_sessions ses ON ses.session_id = req.session_id
    CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext
About these ads
Categories: SQL
  1. September 10, 2012 at 12:42 pm

    Thank you for updated in the query.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 267 other followers

%d bloggers like this: