如何在SQL Server中为存储过程设置超时

时间:2021-07-05 01:08:27

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.

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

thanks

谢谢

1 个解决方案

#1


10  

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.

既然你特意询问了如何设置超时值,我会告诉你,但我同意OMG小马所做的评论,如果你弄清楚为什么查询花了这么长时间,你会好得多。要开始阅读有关查询优化的内容,请阅读此内容。

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

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

  1. Locate your server in SQL Server Management Studio.
  2. 在SQL Server Management Studio中找到您的服务器。
  3. Right click on the server name.
  4. 右键单击服务器名称。
  5. Select properties.
  6. 选择属性。
  7. Choose the Connections tab.
  8. 选择“连接”选项卡。
  9. Set the query timeout value. (The value is in seconds. Set it to 0 for unlimited time)
  10. 设置查询超时值。 (该值以秒为单位。无限时间设置为0)
  11. Click OK.
  12. 单击确定。

如何在SQL Server中为存储过程设置超时

#1


10  

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.

既然你特意询问了如何设置超时值,我会告诉你,但我同意OMG小马所做的评论,如果你弄清楚为什么查询花了这么长时间,你会好得多。要开始阅读有关查询优化的内容,请阅读此内容。

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

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

  1. Locate your server in SQL Server Management Studio.
  2. 在SQL Server Management Studio中找到您的服务器。
  3. Right click on the server name.
  4. 右键单击服务器名称。
  5. Select properties.
  6. 选择属性。
  7. Choose the Connections tab.
  8. 选择“连接”选项卡。
  9. Set the query timeout value. (The value is in seconds. Set it to 0 for unlimited time)
  10. 设置查询超时值。 (该值以秒为单位。无限时间设置为0)
  11. Click OK.
  12. 单击确定。

如何在SQL Server中为存储过程设置超时