Forum Discussion

riyanto's avatar
riyanto
Copper Contributor
Mar 14, 2025

SQL Server does not reduce the size of MDF and LDF

I am a SQL Server 2017 user, I deleted a table that had too many records, but after the delete process, the size of the MDF and LDF files did not decrease, but increased. I have shrunk the file but the file size remains the same. What should I do to change the file size?

  • divyed's avatar
    divyed
    Copper Contributor

    Hello riyanto ,

     

    This is bit tricky but you can follow the steps to shrink files :

    1. Change recovery model of your database to simple . Select your database=> Properties=>Options=> recovey model
    2. Stop sql server services 
    3. Apply shinkfiles instead of shrink database and choose log and data files one by one. Check for available space and set accordingly
    4. Restart sql server services
    5. Change recovery model to full 

    You can take database full backup before applying changes in case anything goes wrong (chances are rare)

     

    I hope this helps.

     

    Did I answer your query ? Mark this as solution if this helps, Kudos are appreciated.

     

    Warm Regards,

    Neeraj

Resources