Forum Discussion

ashish35's avatar
ashish35
Copper Contributor
Jun 18, 2021

SQL Server Bulk Delete Query

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.

  • olafhelper's avatar
    olafhelper
    Bronze Contributor

    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.

Resources