SELECT s_tst.[session_id],
s_es.[login_name] AS [Login Name],
S_tdt.[database_transaction_begin_time] AS [Begin Time],
s_tdt.[database_transaction_log_record_count] AS [Log Records],
s_tdt.[database_transaction_log_bytes_used] AS [Log Bytes],
s_tdt.[database_transaction_log_bytes_reserved] AS [Log Reserved],
s_est.[text] AS [Last T-SQL Text],
s_eqp.[query_plan] AS [Last Query Plan]
FROM sys.dm_tran_database_transactions s_tdt
JOIN sys.dm_tran_session_transactions s_tst
ON s_tst.[transaction_id] = s_tdt.[transaction_id]
JOIN sys.[dm_exec_sessions] s_es
ON s_es.[session_id] = s_tst.[session_id]
JOIN sys.dm_exec_connections s_ec
ON s_ec.[session_id] = s_tst.[session_id]
CROSS APPLY sys.dm_exec_sql_text (s_ec.[most_recent_sql_handle]) AS s_est
OUTER APPLY sys.dm_exec_query_plan (s_ec.[most_recent_sql_handle]) AS s_eqp
ORDER BY [Begin Time] ASC;
Tuesday, February 2, 2010
Find Which Transaction is currently Running
Core AJAX Call from Page
Javascript
function newXMLHttpRequest() {
var xmlreq = false;
if (window.XMLHttpRequest) {
xmlreq = new XMLHttpRequest();
} else if (window.ActiveXObject) {
// Try ActiveX
try {
xmlreq = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e1) {
// first method failed
try {
xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
// both methods failed
}
}
}
return xmlreq;
}
function GetUserInfo(PageURL) {
var req = newXMLHttpRequest();
req.open("POST", PageURL, true);
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
req.setRequestHeader("content-length", "0"); req.send('');
req.onreadystatechange = function() {
if (req.readyState == 4) {
if (req.status == 200) {
alert(req.responseText.toString());
}
}
}
}
Page Method
Code in aspx page :
HTML :
<a href="#" onclick="CheckAvailability()">Check User Availability</a>
<span id="lblCheck"></span>
Javascript :
[System.Web.Services.WebMethod]
public static string CheckUserAvailability(string sUserId, string sUserName)
{
return CommonFunctions.CheckUserAvailability(sUserId, sUserName);
}
HTML :
<a href="#" onclick="CheckAvailability()">Check User Availability</a>
<span id="lblCheck"></span>
Javascript :
function CheckAvailability() {
PageMethods.CheckUserAvailability(document.getElementById('<%= hdnCurrentUserId.ClientID %>').value, document.getElementById('<%= txtUserName.ClientID %>').value, OnSucceededUser, OnFailedUser);
return false;
}
function OnSucceededUser(result, userContext, methodName) {
document.getElementById('lblCheck').innerHTML = result;
return;
}
function OnFailedUser(error, userContext, methodName) {
return;
}
Subscribe to:
Posts (Atom)