How can I stop a SQL query that is running after it exceeds a specific amount of time automatically?
Asked
Active
Viewed 63 times
0
-
How do you execute the query? – HoneyBadger Dec 10 '18 at 10:38
-
using SET LOCK_TIMEOUT 1800; does not work as expected. It just keeps running and retrieving values – Krank Dec 10 '18 at 11:45
-
You could but you probably wouldn't want to... It should be easy enough to monitor for long running queries and executing a KILL command on any offending SPIDs... The problem is that, if that SPID was doing an INSERT, UPDATE or DELETE operation, killing the SPID will trigger a ROLLBACK of that transaction(s). Given that all ROLLBACKs are single threaded, a ROLLBACK can take MUCH longer than the original transaction. – Jason A. Long Dec 10 '18 at 17:20
-
No Insert or update or delete. Just a normal query to retrieve values – Krank Dec 11 '18 at 08:18