C Plus and stopping query in process

  • Hi Everyone!

    Our C++ programmers have asked me to post a question.

    They are using asynchronous and synchronous queries (got me there).

    Anyone know what command can be sent to SQL to stop the execution of a query in progress (but only that query of course)? (Similar to clicking the stop button in the query analyzer.)

    I have checked for cancel and some other keywords but nothing really addresses this.

    Thanks!

  • Are these queries taking minutes to execute? Most queries should only take a second or two tops. Are you running update queries or just selects?

    If you set the commmand timeout property, if using ADO, to a very short interval, the query will terminate when that amount of time is reached.

  • I havent worked much with asynchronous queries - will have to look! Are they using ADO, ODBC, ??

    Andy

  • you could send a kill <spid> command from another connection. It will close the connection <spid> if at all possible.


    Cursors never.
    DTS - only when needed and never to control.

  • I found out from the programmers that they use one thread in asycronous mode for everything and you cannot stop the query once it starts.

    But I liked the idea of the kill command. I may bring it up to him...

    Thanks again everyone!

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

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