{"id":2025,"date":"2012-04-22T13:54:56","date_gmt":"2012-04-22T13:54:56","guid":{"rendered":"http:\/\/enjoyasp.net\/?p=2025"},"modified":"2012-04-24T01:42:26","modified_gmt":"2012-04-24T01:42:26","slug":"%e6%9f%a5%e8%af%a2%e5%bd%93%e5%89%8d%e6%b4%bb%e5%8a%a8%e7%9a%84%e4%ba%8b%e5%8a%a1","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%e6%b4%bb%e5%8a%a8%e7%9a%84%e4%ba%8b%e5%8a%a1\/","title":{"rendered":"\u67e5\u8be2\u5f53\u524d\u6d3b\u52a8\u7684\u4e8b\u52a1"},"content":{"rendered":"<p>\n\tSELECT CASE WHEN TDT.database_id = 32767<br \/>\n\tTHEN &#8216;MSSQLSystemResource&#8217;<br \/>\n\tELSE DB.name END AS DatabaseName<br \/>\n\t,REQ.start_time AS ReqStart<br \/>\n\t,TAT.transaction_begin_time AS TransBegin<br \/>\n\t,TAT.name AS TransName<br \/>\n\t,CASE TDT.database_transaction_type<br \/>\n\tWHEN 1 THEN N&#8217;Read\/Write&#8217;<br \/>\n\tWHEN 2 THEN N&#8217;Read-only&#8217;<br \/>\n\tWHEN 3 THEN N&#8217;System&#8217;<br \/>\n\tELSE N&#8217;Unkown&#8217; END AS TransType<br \/>\n\t,CASE TAT.transaction_state<br \/>\n\tWHEN 0 THEN N&#8217;Not initialized&#8217;<br \/>\n\tWHEN 1 THEN N&#8217;Not started&#8217;<br \/>\n\tWHEN 2 THEN N&#8217;Active&#8217;<br \/>\n\tWHEN 3 THEN N&#8217;Ended&#8217;<br \/>\n\tWHEN 4 THEN N&#8217;DTC active&#8217;<br \/>\n\tWHEN 5 THEN N&#8217;Preparing&#8217;<br \/>\n\tWHEN 6 THEN N&#8217;Committing&#8217;<br \/>\n\tWHEN 7 THEN N&#8217;Being rolled back&#8217;<br \/>\n\tWHEN 8 THEN N&#8217;Rolled back&#8217;<br \/>\n\tELSE N&#8217;Unkown&#8217;<br \/>\n\tEND AS TransState<br \/>\n\t,REQ.[status] AS ReqStatus<br \/>\n\t,TDT.database_transaction_log_record_count AS LogRec<br \/>\n\t,TDT.database_transaction_log_bytes_used AS LogBytes<br \/>\n\t,SES.login_name AS LoginName<br \/>\n\t,REQ.wait_type AS ReqWaitType<br \/>\n\t,REQ.percent_complete AS [ReqCompl%]<br \/>\n\t,REQ.command AS ReqCommand<br \/>\n\t,SUBSTRING(EST.text<br \/>\n\t,1 + REQ.statement_start_offset \/ 2<br \/>\n\t,(CASE WHEN REQ.statement_end_offset = -1<br \/>\n\tTHEN LEN(convert(nvarchar(max), EST.text)) * 2<br \/>\n\tELSE REQ.statement_end_offset END &#8211; REQ.statement_start_offset) \/ 2<br \/>\n\t) AS SqlStatement<br \/>\n\tFROM sys.dm_tran_active_transactions AS TAT<br \/>\n\tINNER JOIN sys.dm_tran_database_transactions AS TDT<br \/>\n\tON TAT.transaction_id = TDT.transaction_id<br \/>\n\tINNER JOIN sys.databases AS DB<br \/>\n\tON TDT.database_id = DB.database_id<br \/>\n\tLEFT JOIN sys.dm_tran_session_transactions AS TST<br \/>\n\tON TAT.transaction_id = TST.transaction_id<br \/>\n\tLEFT JOIN sys.dm_exec_requests AS REQ<br \/>\n\tON TAT.transaction_id = REQ.transaction_id<br \/>\n\tLEFT JOIN sys.dm_exec_sessions AS SES<br \/>\n\tON REQ.session_id = SES.session_id<br \/>\n\tCROSS APPLY sys.dm_exec_sql_text(REQ.sql_handle) AS EST<br \/>\n\tWHERE TAT.transaction_id > 255<br \/>\n\tAND ISNULL(REQ.session_id, -1) <> @@SPID<br \/>\n\tAND TDT.database_id <> DB_ID(N&#8217;tempdb&#8217;)<br \/>\n\tORDER BY DatabaseName<br \/>\n\t,TransBegin<br \/>\n\t,TransName;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SELECT CASE WHEN TDT.database_id = 32767 THEN &#8216;MS [&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-2025","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\/2025","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=2025"}],"version-history":[{"count":0,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts\/2025\/revisions"}],"wp:attachment":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/media?parent=2025"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/categories?post=2025"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/tags?post=2025"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}