Cancel a SQL Server Query
-
Please help me understand what happens when I click the cancel query button in SQL Server Management Studio. Please help me understand what happens when I click the cancel query button in SQL Server Management Studio. I was running a delete query in SQL Server 2005 on a pretty slow machine with low resources on a pretty big database table. After about 2.5 hours, I got a message that I was running low on disk space and when I checked, drive C had 5MB free out of 75GB. Anyway, I went to cancel the query and here I sit, one hour later and it still says "Canceling Query". Am I going to have to wait another hour and a half for this? Will any of the deletes have been committed or did I just waste 3 and a half hours of time?
-
Answer:
The deletes won't be committed. You're running out of disk space because it has to log all of those deletes so they can be rolled back if the statement terminates (which is what it's doing while you wait for it to cancel). If you want to delete all records in the table, try using TRUNCATE instead (which isn't logged). If you need to delete only part of the records, try rewriting your query to delete a smaller number of records at a time (say 1000), and then run the query repeatedly until everything you want is gone. You might also try dropping any indexes on the table, and dropping any foreign keys from other tables TO your table, while deleting, and then re-create them afterwards. It may run much quicker that way.
smithygreg at Ask.Metafilter.Com Visit the source
Other answers
Also here's some info to get your disk space back: http://support.microsoft.com/?kbid=873235
Emanuel
Thanks Emanuel... I wound up just dropping the table altogether and recreating it.
smithygreg
Related Q & A:
- What is the best practice for free space for a SQL server database drive?Best solution by Database Administrators
- How to restrict access to a sql server database from Azure?Best solution by Stack Overflow
- How to convert a SQL query into hibernate criteria?Best solution by Stack Overflow
- How to change column data's as a separate column wise format in a SQL Server?Best solution by stackoverflow.com
- How do I connect to a SQL Server database?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.