本文介绍了如何立即终止/停止长 SQL 查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 SQL Server 2008 及其管理工作室.我执行了一个产生多行的查询.我试图通过红色取消按钮取消它,但它在过去 10 分钟内没有停止.它通常在 3 分钟内停止.

I am using SQL server 2008 and its management studio. I executed a query that yields many rows. I tried to cancel it via the red cancel button, but it has not stopped for the past 10 minutes. It usually stops within 3 minutes.

可能是什么原因,我该如何立即停止?

What could the reason be and how do I stop it immediately ?

推荐答案

立即取消查询,前提是您的注意力到达服务器并进行处理.查询必须处于可取消状态,这几乎总是正确的,除非您执行某些操作,例如从 SQLCLR 调用 Web 服务.如果您的注意力无法到达服务器,通常是由于 scheduler 过载.

A query cancel is immediate, provided that your attention can reach the server and be processed. A query must be in a cancelable state, which is almost always true except if you do certain operations like calling a web service from SQLCLR. If your attention cannot reach the server it's usually due to scheduler overload.

但是如果您的查询是必须回滚的事务的一部分,则回滚不能被中断.如果需要 10 分钟,那么它需要 10 分钟,而您对此无能为力.即使重新启动服务器也无济于事,它只会使启动时间更长,因为恢复必须完成回滚.

But if your query is part of a transaction that must rollback, then rollback cannot be interrupted. If it takes 10 minutes then it needs 10 minutes and there's nothing you can do about it. Even restarting the server will not help, it will only make startup longer since recovery must finish the rollback.

要回答哪个适用于您的案例的具体原因,您需要自行调查.

To answer which specific reason applies to your case, you'll need to investigate yourself.

这篇关于如何立即终止/停止长 SQL 查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 03:43