2

I am executing a query and stored procedure against MS SQL Server. Both php script and sql server reside on the same server. Sometimes it takes too much time to execute and the PHP script crashes. However SQL Server continues executing the queries in the background.

How can I force SQL Server to stop any queries which take more than X seconds to execute?

1
  • 1
    Why does this query take so long to run?? When the php script "crashes" I assume you mean it times out. Commented Feb 17, 2012 at 17:00

3 Answers 3

4

You can use a server level setting, see Microsoft documentation.

  1. In Object Explorer, right-click a server and select Properties.
  2. Click the Connections node.
  3. Under Remote server connections, in the Remote query timeout box, type or select a value from 0 through 2,147,483,647 to set the maximum number seconds for SQL Server to wait before timing out.
Sign up to request clarification or add additional context in comments.

1 Comment

"remote query timeout" affects only queries over linked server in SQL Server. As Microsoft says: "his value has no effect on queries received by the Database Engine." (ref: learn.microsoft.com/en-us/previous-versions/sql/…)
0

Also you can increase the execution time of php via max_execution_time setting in your php.ini file or using the function set_time_limit in your php file

Comments

-1

There's a configuration parameter in PHP: mssql.timeout which defaults to 60 seconds and limits time to execute queries. After this time the MSSQL PHP driver will abort the query and report query timeout error.

But there's no such thing as "query timeout" in SQL Server itself :-)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.