Queries that are memory intensive and involve huge sorts might take a long time to execute, based on the available memory during execution. SQL Server internally calculates the timeout interval for such queries. Usually, this is quite a large number. You can override this value by specifying a value (in seconds) for the
query wait parameter in SQL Server. If you set this value too low, you risk more frequent query timeouts when your system is under a heavy load and a highly concurrent environment. If
-1 is specified (the default), the timeout is calculated as 25 times of the estimated query cost.
The following is an example of this option:
exec sp_configure 'query wait', ...