SQL Server connection and transaction-related issues.

Source: Internet
Author: User

Method 1, DBCC OPENTRAN + sys.dm_exec_connections

DBCC OPENTRAN;

You can see that the driest activity was initiated by the 54 session. Let's take a look at what it does.

Select Conn.session_id,sess.program_name,sqltext.text
From Sys.dm_exec_connections as Conn cross apply Sys.dm_exec_sql_text (Conn.most_recent_sql_handle) as Sqltext,sys.dm_ Exec_sessions Sess
where conn.session_id = sess.session_id and conn.session_id = 54;
Go

Here you can see that session 54 is the last thing to do is ' SELECT @ @spid ' Remember the oldest activity transaction is 54 open? But this business is not open for @ @spid

Summarize:

DBCC OPENTRAN only returns the most active transaction, not the last transaction of the session, Sys.dm_exec_connections can only get the SQL code reference of the last transaction.

To find the oldest transaction what it is doing, this method still does not work.

SQL Server connection and transaction-related issues.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.