gpt4 book ai didi

sql-server - SQL Server - 挂起进程 - SPID 查询

转载 作者:行者123 更新时间:2023-12-02 07:39:24 27 4
gpt4 key购买 nike

如果我有 SPID,如何找到正在执行的关联查询是什么。尝试找出正在关联的查询,因为该进程似乎已挂起。

最佳答案

--Find Current SQL Statements that are Running
SELECT SPID = er.session_id
,STATUS = ses.STATUS
,[Login] = ses.login_name
,Host = ses.host_name
,BlkBy = er.blocking_session_id
,DBName = DB_Name(er.database_id)
,CommandType = er.command
,ObjectName = OBJECT_NAME(st.objectid)
,CPUTime = er.cpu_time
,StartTime = er.start_time
,TimeElapsed = CAST(GETDATE() - er.start_time AS TIME)
,SQLStatement = st.text
FROM sys.dm_exec_requests er
OUTER APPLY sys.dm_exec_sql_text(er.sql_handle) st
LEFT JOIN sys.dm_exec_sessions ses
ON ses.session_id = er.session_id
LEFT JOIN sys.dm_exec_connections con
ON con.session_id = ses.session_id
WHERE st.text IS NOT NULL

关于sql-server - SQL Server - 挂起进程 - SPID 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5198215/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com