{"id":2027,"date":"2012-04-22T14:01:16","date_gmt":"2012-04-22T14:01:16","guid":{"rendered":"http:\/\/enjoyasp.net\/?p=2027"},"modified":"2012-06-08T14:38:04","modified_gmt":"2012-06-08T14:38:04","slug":"%e6%9f%a5%e8%af%a2%e5%bd%93%e5%89%8d%e4%ba%8b%e5%8a%a1%e4%b8%ad%e7%9a%84%e9%94%81","status":"publish","type":"post","link":"https:\/\/enjoyasp.net\/index.php\/2012\/04\/22\/%e6%9f%a5%e8%af%a2%e5%bd%93%e5%89%8d%e4%ba%8b%e5%8a%a1%e4%b8%ad%e7%9a%84%e9%94%81\/","title":{"rendered":"\u67e5\u8be2\u5f53\u524d\u4e8b\u52a1\u4e2d\u7684\u9501\uff0c\u53ca\u76f8\u5173sql\u8bed\u53e5"},"content":{"rendered":"<p>\nSELECT TL.resource_type AS ResType<br \/>\n,TL.resource_description AS ResDescr<br \/>\n,TL.request_mode AS ReqMode<br \/>\n,TL.request_type AS ReqType<br \/>\n,TL.request_status AS ReqStatus<br \/>\n,TL.request_owner_type AS ReqOwnerType<br \/>\n,TAT.[name] AS TransName<br \/>\n,TAT.transaction_begin_time AS TransBegin<br \/>\n,DATEDIFF(ss, TAT.transaction_begin_time, GETDATE()) AS TransDura<br \/>\n,ES.session_id AS S_Id<br \/>\n,ES.login_name AS LoginName<br \/>\n,COALESCE(OBJ.name, PAROBJ.name) AS ObjectName<br \/>\n,PARIDX.name AS IndexName<br \/>\n,ES.host_name AS HostName<br \/>\n,ES.program_name AS ProgramName<br \/>\n,REQ.command AS ReqCommand<br \/>\n,SUBSTRING(EST.text<br \/>\n,1 + REQ.statement_start_offset \/ 2<br \/>\n,(CASE WHEN REQ.statement_end_offset = -1<br \/>\nTHEN LEN(convert(nvarchar(max), EST.text)) * 2<!--more--><!--more--><br \/>\nELSE REQ.statement_end_offset END &#8211; REQ.statement_start_offset) \/ 2<br \/>\n) AS SqlStatement<br \/>\nFROM sys.dm_tran_locks AS TL<br \/>\nINNER JOIN sys.dm_exec_sessions AS ES<br \/>\nON TL.request_session_id = ES.session_id<br \/>\nLEFT JOIN sys.dm_tran_active_transactions AS TAT<br \/>\nON TL.request_owner_id = TAT.transaction_id<br \/>\nAND TL.request_owner_type = &#39;TRANSACTION&#39;<br \/>\nLEFT JOIN sys.objects AS OBJ<br \/>\nON TL.resource_associated_entity_id = OBJ.object_id<br \/>\nAND TL.resource_type = &#39;OBJECT&#39;<br \/>\nLEFT JOIN sys.partitions AS PAR<br \/>\nON TL.resource_associated_entity_id = PAR.hobt_id<br \/>\nAND TL.resource_type IN (&#39;PAGE&#39;, &#39;KEY&#39;, &#39;RID&#39;, &#39;HOBT&#39;)<\/p>\n<p>LEFT JOIN sys.objects AS PAROBJ<br \/>\nON PAR.object_id = PAROBJ.object_id<br \/>\nLEFT JOIN sys.indexes AS PARIDX<br \/>\nON PAR.object_id = PARIDX.object_id<br \/>\nAND PAR.index_id = PARIDX.index_id<br \/>\nLEFT JOIN sys.dm_exec_requests AS REQ<br \/>\nON TAT.transaction_id = REQ.transaction_id<br \/>\nouter APPLY sys.dm_exec_sql_text(REQ.sql_handle) AS EST<\/p>\n<p>WHERE TL.resource_database_id = DB_ID()<br \/>\nAND ES.session_id &lt;&gt; @@Spid<br \/>\nAND TL.request_mode like&nbsp; &#39;%x%&#39;<br \/>\nORDER BY TL.resource_type<br \/>\n,TL.request_mode<br \/>\n,TL.request_type<br \/>\n,TL.request_status<br \/>\n,ObjectName<br \/>\n,ES.login_name;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SELECT TL.resource_type AS ResType ,TL.resource_descrip [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-2027","post","type-post","status-publish","format-standard","hentry","category-sql-server"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts\/2027","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/comments?post=2027"}],"version-history":[{"count":0,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts\/2027\/revisions"}],"wp:attachment":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/media?parent=2027"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/categories?post=2027"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/tags?post=2027"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}