TABLE OF CONTENTS
- •Best Practices for SQL Server Shrink
- •Category: Reliability
- •What Is Shrinking a Database in SQL?
- •Why shouldn’t you shrink your data files?
- •Best practices recommend against enabling it, so check whether it’s disabled.
- •Need expert support for SQL Server?
- •Leave Your Day-to-Day SQL Server Operations to Us
Best Practices for SQL Server Shrink
Category: Reliability
What Is Shrinking a Database in SQL?
Shrinking data files reclaims space by moving data pages and returning that space back to the file system.
Why shouldn’t you shrink your data files?
Regularly shrinking databases (data files, to be more specific) is a bad idea.
It consumes resources and creates serious index fragmentation.
Make Sure Auto Shrink Is Disabled
Best practices recommend against enabling it, so check whether it’s disabled.
- Expand Databases using SSMS.
- Right-click the database name and select Properties.
- On the Options page, set the Auto Shrink property to False, then click OK.
You can also turn off the AUTO_SHRINK database option using T-SQL, as shown below (make sure to replace “yourdb” with your database name).
ALTER DATABASE yourdb SET AUTO_SHRINK OFF
Note: The SQL Server Auto Shrink feature is disabled by default on SQL Server instance databases.
Sometimes You May Need to Shrink Data Files Anyway.
Only use DBCC SHRINKFILE in exceptional situations — for example, if you’ve deleted a large amount of data that won’t be added back soon, or dropped several large (unused) indexes.
In these cases (or both):
- Identify low-usage server hours during which you can run the shrink.
- Monitor Agent Jobs and watch for SQL Server blocking if there’s no outage window.
- Use DBCC SHRINKFILE and set a specific, targeted size for the file you’re shrinking.
- Once the shrink is done, use ALTER INDEX REORGANIZE to reduce index fragmentation.
- Finally, shrink the log file, then explicitly grow it back to keep the VLF count low.
Need expert support for SQL Server?
Our senior database team supports SQL Server performance tuning, health checks, migrations, Remote DBA services and urgent operational issues.
Related Reading
SQL Server Managed DBA Services
Leave Your Day-to-Day SQL Server Operations to Us
Aryasoft’s Remote DBA team continuously and proactively manages your maintenance plans, job/agent management, and server operations.