Sometimes my application runs slow. The major problem is that some expensive reports are running. How can I find these reports and how to kill these instantly?
You can find which queries are running from a long time and utilizing CPU. To run this query, start SQL Server Management Studio, Open New Querywindow and copy below query in it. Now click on Executebutton to run this query.
This will help you find currently running SQL queries on SQL Server. You can find which queries are running from a long time and utilizing CPU. To run this query, start SQL Server Management Studio, Open New Query window and copy below query in it. Now click on Execute button to run this query. SELECT sqltext.TEXT, req.session_id, req.status, ...
You can use a keyboard shortcut ALT + Break to stop the query execution. However, this may not succeed in all cases. Show activity on this post. Find Session-Id and Description for respective all running queries and then copy specific query's Session-Id which you want to kill/stop immediately. Show activity on this post.
To run this query, start SQL Server Management Studio, Open New Querywindow and copy below query in it. Now click on Executebutton to run this query.
You can use the following command to get the long running queries.
SELECT r.session_id,
st.TEXT AS batch_text,
qp.query_plan AS 'XML Plan',
r.start_time,
r.status,
r.total_elapsed_time
FROM sys.dm_exec_requests AS r
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) AS st
CROSS APPLY sys.dm_exec_query_plan(r.plan_handle) AS qp
WHERE DB_NAME(r.database_id) = '{db_name}'
ORDER BY cpu_time DESC;
Then you can use
KILL 60
to kill session_id 60 for example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With