sqlserver 锁表进程及执行的SQL


--1、查进程
select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) tableName
from sys.dm_tran_locks where resource_type='OBJECT'
order by request_session_id

--2、查sql select er.session_id, CAST(csql.text AS varchar(2000)) AS CallingSQL from master.sys.dm_exec_requests er WITH (NOLOCK) CROSS APPLY fn_get_sql (er.sql_handle) csql where er.session_id =52
---------

posted @ 2019-06-28 12:30  kuailewangzi1212  阅读(840)  评论(0编辑  收藏  举报