Check current executing Query over the server :-
- Reza
- Dec 14, 2016
- 1 min read
Some times we are inserting bulk data into the production but we are not able to insert.
The reason behind it it may be an another user inserting or performing on same database.
In this case we need to track the query which statement they are currently executing.
If you execute the below Query you will get the result.
SELECT SPID = er.session_id
,STATUS = ses.STATUS
,[Login] = ses.login_name
,Host = ses.host_name
,BlkBy = er.blocking_session_id
,DBName = DB_Name(er.database_id)
,CommandType = er.command
,ObjectName = OBJECT_NAME(st.objectid)
,CPUTime = er.cpu_time
,StartTime = er.start_time
,TimeElapsed = CAST(GETDATE() - er.start_time AS TIME)
,SQLStatement = st.text
FROM sys.dm_exec_requests er
OUTER APPLY sys.dm_exec_sql_text(er.sql_handle) st
LEFT JOIN sys.dm_exec_sessions ses
ON ses.session_id = er.session_id
LEFT JOIN sys.dm_exec_connections con
ON con.session_id = ses.session_id
WHERE st.text IS NOT NULL
OUTPUT : -

Recent Posts
See All/*How to count a string that number of times has repeated in a table rows. Here i just passes the values by dynamically. please lets have...
Comments