Forum Discussion
riyanto
Mar 14, 2025Copper Contributor
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?
- divyedCopper Contributor
Hello riyanto ,
This is bit tricky but you can follow the steps to shrink files :
- Change recovery model of your database to simple . Select your database=> Properties=>Options=> recovey model
- Stop sql server services
- Apply shinkfiles instead of shrink database and choose log and data files one by one. Check for available space and set accordingly
- Restart sql server services
- 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
- olafhelperBronze Contributor
the size of the MDF and LDF files did not decrease,
Of course not, SQL Server never decrease the file size on it's own, it's an expensive IO operation.
Run a DBCC SHRINKFILE (Transact-SQL) - SQL Server | Microsoft Learn