SQL Server Bulk Delete Query

Copper Contributor

In order to reclaim space from Audit table records, I deleted the rows from the Table and rebuilded Index. But later I came to know that these tables were not having any indexes. So after deletion, the storage space got occupied more instead of reducing because of Tx logs + Indexes got increased.

 

Please suggest me the correct action over here to reclaim the space.

1 Reply

@ashish35 , if you mean you have a heap table = no clustered index, then you can rebuild the table as it to defrag the table & get back some space, like

 

ALTER TABLE yourTableName WITH REBUILD;

The table will be completley locked dureing the operation, so better schedule if for off-work hour.