What Happens To a Query If It Times Out?

前端 未结 5 589
广开言路
广开言路 2020-12-16 15:34

Let\'s say I have a query that is sent to my SQL-Server database, it takes more than 30 seconds, and my program throws an SQL Query Timeout exception. Is the query still ch

5条回答
  •  失恋的感觉
    2020-12-16 16:18

    Usually when it times out it means the connection has died, meaning the query has not been sent to the database, most database support Transactions where you can start a transaction, run your queries, and if your happy you can commit them.

    Example:

    BEGIN TRAN
    
    UPDATE  authors
       SET  au_fname = 'John'
    WHERE   au_id = '172-32-1176'
    
    UPDATE  authors
       SET  au_fname = 'Marg'
    WHERE   au_id = '213-46-8915'
    
    COMMIT TRAN
    

提交回复
热议问题