Query Timeout

  • Hi,

    I've just been presented with a potential scenario where I will need to execute a procedure to return a result set, if this query executes in less than a given number of seconds then I will need to re-execute the procedure (different parameters) and so on.

    However if the procedure execution lasts longer than the number of given seconds then I will want to abort the procedure execution and just return the result of any previous executions (which I will of stored away).

    So my question is, is it possible to say, attempt to execute this procedure, if it takes longer than x number of seconds then raise an error or something. I know we can do this on the server, but is it possible in 2K5 to set this timeout for just one query execution?

    Thanks,

    Jackal

  • SQL has no concept of timeouts (other that lock timeouts). A timeout is a client application setting that controls how long the client app is willing to wait the server to finish before cancelling the query. If you need to set a timeout, you have to do that in the front end application.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • It is possible to set a maximum timeout value for remote queries, at the server level, but that won't do what you're looking for. For that, it would need to be set up in the application calling the queries, whether that's a data connection layer or a front-end application.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Thankyou both for the reply.

    Your help is much appreciated.

    Jackal

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply