1

We connect to our customer's database server with vpn. Sometimes we manage Sql server to connect database server or to connect with ssms in our pc's.
I executed a query with ssms in database server, then the connection has gone down. I have tried to connect many times but failed. I have to cancel this query.

I can connect with ssms in my pc's. Can I cancel query with ssms in my pc?

2

Step 1: Get query session id using below query

SELECT sqltext.TEXT,
req.session_id,----- SPID
req.status,
req.command,
req.cpu_time,
req.total_elapsed_time,req.start_time,db_name(database_id) DatabaseName
FROM sys.dm_exec_requests req
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext
where [status] <> 'background'
and command<> 'TASK MANAGER'

enter image description here

Step 2: use kill command to kill the process execution

Kill(53) -- KIll (SPID)
1

Use KILL (SPID) to kill the query.

Not the answer you're looking for? Browse other questions tagged or ask your own question.