BUG: Kill running query when user doesn't have admin privileges

igitur's profile image igitur posted 8 years ago in General Permalink

Hi,

On most of the MS SQL servers that I use I don't have admin / sa privileges. Sometimes I have a long running query that I want to stop. If I press the stop button, the kill command is sent to the server. I get a permission denied error for that and HeidiSQL throws an exception (I can attach it if you want). The problem is that from then on HeidiSQL is very unstable and a lot of actions cause exceptions. I'm also unable to close that tab, because HeidiSQL says a query is currently running.

I suspect a proper absorption of any exceptions thrown by the kill command would solve it.

Francois

Code modification/commit 5152fca from ansgarbecker, 8 years ago, revision 9.3.0.5124
Catch exception when clicking "Cancel running operation" and the KILL command cannot be executed. See http://www.heidisql.com/forum.php?t=22339
ansgar's profile image ansgar posted 8 years ago Permalink

r5124 now catches such exceptions within executing the KILL command.

igitur's profile image igitur posted 8 years ago Permalink

The exception on the kill command is now caught, but HeidiSQL still thinks the query is running.

ansgar's profile image ansgar posted 8 years ago Permalink

Well it is running, when the KILL command did not succeed, doesn't it?

igitur's profile image igitur posted 8 years ago Permalink

Ah OK. You're right. It is actually still running. How does SSMS stop the queries then? In SSMS I just hit the stop button and the query stops with message "Query was cancelled by user."

igitur's profile image igitur posted 8 years ago Permalink
/* Affected rows: 0  Found rows: 22 825  Warnings: 0  Duration for 1 query: 01:05:16 */

See why I want to kill the query? ;)

ansgar's profile image ansgar posted 8 years ago Permalink

Hehe. Well, take a coffee, or two, or have a talk with your colleagues :)

igitur's profile image igitur posted 8 years ago Permalink

Haha, I do that a lot.

But seriously, is there no way to at least abandon the query? I'm not sure, but I think that's what SSMS does when you press the stop button and don't have privileges to kill the query... I think it just abandons the SQL command, but that it actually continues running on the server. Would that be possible in HeidiSQL?

ansgar's profile image ansgar posted 8 years ago Permalink

The only chance for me is to kill the connection then programmatically, without SQL. That would destroy the old session and create a new one. But that cannot be the intention of a "Cancel running query" button.

Please login to leave a reply, or register at first.