If I stop a long running query, does it rollback?

后端 未结 12 1932
忘了有多久
忘了有多久 2020-12-06 04:23

A query that is used to loop through 17 millions records to remove duplicates has been running now for about 16 hours and I wanted to know if the query is sto

12条回答
  •  猫巷女王i
    2020-12-06 04:57

    no, sql server will not roll back the deletes it has already performed if you stop query execution. oracle requires an explicit committal of action queries or the data gets rolled back, but not mssql.

    with sql server it will not roll back unless you are specifically running in the context of a transaction and you rollback that transaction, or the connection closes without the transaction having been committed. but i don't see a transaction context in your above query.

    you could also try re-structuring your query to make the deletes a little more efficient, but essentially if the specs of your box are not up to snuff then you might be stuck waiting it out.

    going forward, you should create a unique index on the table to keep yourself from having to go through this again.

提交回复
热议问题