如何为 SQL Server 中的存储过程设置超时 [英] How to set timeout for a stored procedure in SQL Server

查看:85
本文介绍了如何为 SQL Server 中的存储过程设置超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 SQL Server 中有一个存储过程,我想为我的 sprpc 设置一个超时,以便如果它没有在适当的时间完成,SQL Server 会强制它停止.

I have a stored procedure in SQL Server, I want to set a time out for my sprpc so that if it does not finish in appropriate time, SQL Server forces it to stop.

谢谢

推荐答案

既然你专门问了如何设置超时值,我就告诉你,不过我同意评论OMG Ponies如果您弄清楚为什么查询需要这么长时间,那么您的情况会好得多.要开始阅读有关查询优化的信息,请阅读本文这个.

Since you asked specifically about how to set the timeout value, I'll tell you, but I agree with the comment OMG Ponies made, that you are far better off if you figure out why the query is taking so long. To start reading about query optimization, read this and this.

以下是在服务器上设置查询超时的步骤:

Here are the steps to setting the Query Timeout on the server:

  1. 在 SQL Server Management Studio 中找到您的服务器.
  2. 右键单击服务器名称.
  3. 选择属性.
  4. 选择连接选项卡.
  5. 设置查询超时值.(该值以秒为单位.将其设置为 0 表示无限时间)
  6. 点击确定.

这篇关于如何为 SQL Server 中的存储过程设置超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆