1

Is it possible to limit the amount of time SQL Server takes to query a database?

Having the program returning all results that fit the query that it could find in the time frame?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

3 Answers3

1

Ok, this is my opinion about this question:

Please do not do this to your database. Perhaps you could play with the timeout on a connection level and stream results asap, however... if your database is that big, I guess it's important. Do not abuse your infrastructure like this...

Consider limiting the number of results (SELECT TOP <rows> * FROM ...)

Or use some other sort of (virtual) paging. Again: do not abuse the connection timeout on purpose...

Rick
  • 3,361
  • 1
  • 22
  • 29
0

No sql server does this, it's possible to configure a job that will make a kill process with a long lead time, but this is all very wrong. For this use sys.dm_exec_query_stats https://learn.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/sys-dm-exec-query-stats-transact-sql But this is a very wrong tactic

Stanislav Kundii
  • 2,874
  • 1
  • 11
  • 17
0

If you're writing a web application for example you can specify command timeout. This will send a kill signal for the query when the timeout expires. The kill signal is not handled immediately by the SQL engine but during the next opportunity.