Reputation: 29
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?
Upvotes: 2
Views: 15406
Reputation: 308
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
Upvotes: 0
Reputation: 39
You can use a server level setting, see Microsoft documentation.
- In Object Explorer, right-click a server and select Properties.
- Click the Connections node.
- 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.
Upvotes: 4
Reputation: 2456
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 :-)
Upvotes: -1