Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Currently running queries in SQL Server [duplicate]

Tags:

Is there a program or a sql query that I can find which SQL queries are being run on an SQL Server 2012? I think there was a tool in earlier version of SQL Server where the actual query content gets displayed or the stored procedure name?

like image 727
iefpw Avatar asked May 26 '12 15:05

iefpw


People also ask

Why am I getting duplicate rows in SQL?

You are getting duplicates because more than one row matches your conditions. To prevent duplicates use the DISTINCT keyword: SELECT DISTINCT respid, cq4_1, dma etc...


1 Answers

Depending on your privileges, this query might work:

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

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

like image 94
Hari Menon Avatar answered Oct 18 '22 06:10

Hari Menon