How to present large dataset from a SQL Server query?

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

Was this solution helpful to you?

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

Just Added Q & A:

Find solution

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.