Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Shrinking (compression)

Reclaim unused SQL database space safely with SQL Server Management Studio.

If you are running SQL Express and one of the databases exceeds 10 GB, you have only two options: purchase SQL Standard/Enterprise from Microsoft, or replace the database with a blank one. Gallagher cannot alter or shrink a database that Microsoft has marked read-only after reaching the SQL Express cap.


Shrinking (from v7.70+)

If a database is approaching 10 GB on SQL Express and you believe it contains empty space, you can shrink it through SSMS. Empty space comes from deleting or archiving data: when you archive events, the events are replaced with empty space and the database size does not shrink automatically.

To shrink in SSMS, right-click the database and go to Tasks > Shrink > Files.

SSMS right-click Tasks > Shrink > Files menu

Shrink both the main Data file (.mdf) and the Log file (.ldf). Note that the operation only shrinks the file by the amount shown in Available free space.

Shrink File dialog showing the .mdf data file and Available free space

Select Log from the File type: dropdown to shrink the .ldf file.

Shrink File dialog with Log selected in the File type dropdown

Press OK on each to perform the operation. Depending on the file size and the space being reclaimed, this can take from seconds to a few minutes. If the available free space is very small (500 MB or less) there is no real reason to perform the operation, though it will still reclaim the amount shown.


🔗 Related

Last updated

Was this helpful?