Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Get more than 10 minutes of SQL script regardless of whether it caused the lock or not

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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, datediff (MINUTE,start_time,GETDATE ()) duration_time_seconds

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-- Ignore system spids.

AND session_id NOT IN (@ @ SPID)-Ignore this current statement.

And datediff (MINUTE,start_time,GETDATE ()) > 10

ORDER BY 1

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report