Sql-server – Delete query does not appear to open space on the SQL Server

deleteshrinksql server

Our SQL Server (version 2012) is housed on a cloud server, for which we pay whenever we need additional space. We determined that we could delete some of the data to prevent the need for continually buying more storage.

The delete queries did not appear to open space – the size of the drive and available space doesn't change.

It is my understanding that even though available space has not changed, available space is created by the delete query. So new records imported can populate places where data was deleted. Is this correct?

I understand the Shrink Database is not a good choice.

Should I run – sp_clean_db_file_free_space based on the following advice?

http://www.experts-exchange.com/questions/27905050/Freeing-up-disk-space-by-deleting-records-in-a-SQL-Server-2008-table.html

Best Answer

  1. Deleting rows from a table does not automatically free up space, unless you happen to delete a large chunk of rows that are stored on the same pages, and every row on each such page was marked for deletion. You would need to rebuild the indexes in order to reclaim the space.
  2. Even if you rebuild the indexes, SQL Server doesn't reduce the size of the data file(s) just because you've removed some data inside the file. The assumption is typically that if the database got that big once, it will get that big again, so why shrink the file only to grow it again later? Both shrink and growth operations are extremely disruptive to normal activity. Please read this thread in full to understand why you want to be very careful about freeing up space on your drive (even on a cloud-hosted server):

Also see: