Which SQL Statements are Currently Executing on my Database? | SansSQL

Thursday, November 13, 2008

Which SQL Statements are Currently Executing on my Database?

SELECT [Spid] = session_Id
, ecid
, [Database] = DB_NAME(sp.dbid)
, [User] = nt_username
, [Status] = er.status
, [Wait] = wait_type
, [Individual Query] = SUBSTRING (qt.text, er.statement_start_offset/2,
(CASE WHEN er.statement_end_offset = -1
THEN LEN(CONVERT(NVARCHAR(MAX), qt.text)) * 2
ELSE er.statement_end_offset END - er.statement_start_offset)/2)
,[Parent Query] = qt.text
, Program = program_name
, Hostname
, nt_domain
, start_time
FROM sys.dm_exec_requests er
INNER JOIN sys.sysprocesses sp ON er.session_id = sp.spid
CROSS APPLY sys.dm_exec_sql_text(er.sql_handle) as qt
WHERE session_Id > 50 -- This is to ignore system SPID's.
AND session_Id NOT IN (@@SPID) -- This is to ignore this current Statement/Session.

4 comments:

Huongkv said...

Mua vé tại Aivivu, tham khảo

vé máy bay đi Mỹ giá rẻ

các chuyến bay từ mỹ về việt nam hôm nay

ve may bay tu canada ve viet nam

vé máy bay về việt nam từ nhật

Có chuyến bay từ Hàn Quốc về Việt Nam không

Vé máy bay từ Đài Loan về Việt Nam

khách sạn cách ly

vé máy bay cho chuyên gia nước ngoài

Anonymous said...

You provide the informative information related to database in detail. I learn more through this post. Further, The power washing services Boston present the outstanding work.

MartenJames said...

In short time, we got best knowledge from your article. We are always here to provide you Professional Floor Repair Services Chicago IL that are trusted and budget-friendly.

Jone Martin said...

I had read your reviews. developers are happy from you. You keep them update toward the SQL updations.
Likely, I am updating you about the Local Moving Services in Atlanta GA. This give you reliable service and rapid response.

Post a Comment

Ads