> For the complete documentation index, see [llms.txt](https://help.security.gallagher.com/knowledge-hub/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.security.gallagher.com/knowledge-hub/products/cc-software/configure/databases-an-overview-of-command-centr/databases-compressing-or-shrinking-the.md).

# Shrinking (compression)

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

{% hint style="info" %}
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.
{% endhint %}

{% hint style="warning" %}
Create a backup of any database before you do maintenance on it.
{% endhint %}

***

#### 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](https://328339335-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6bM8WhlBE9BYizPWJaPN%2Fuploads%2Fgit-blob-f7fd4d914b49ae07459c6312fc60fc0d6fc4ac7a%2FSECHUB-CCS-SQL-SHRINK-tasks-menu.png?alt=media)

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](https://328339335-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6bM8WhlBE9BYizPWJaPN%2Fuploads%2Fgit-blob-bfd1741cdf885911a271dbf09854470b9d9dc490%2FSECHUB-CCS-SQL-SHRINK-dialog-mdf.png?alt=media)

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

![Shrink File dialog with Log selected in the File type dropdown](https://328339335-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6bM8WhlBE9BYizPWJaPN%2Fuploads%2Fgit-blob-d1cefe6b9d9de4ef771d4e00709445daca6cf409%2FSECHUB-CCS-SQL-SHRINK-dialog-ldf.png?alt=media)

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**

* [Archiving - An Overview](/knowledge-hub/products/cc-software/configure/archiving-and-backups/archiving-an-overview.md). Archiving is what frees the space you then reclaim.
* [Databases - Sizes and Examples](/knowledge-hub/products/cc-software/reference/databases-sizes-and-examples.md). How the databases grow.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.security.gallagher.com/knowledge-hub/products/cc-software/configure/databases-an-overview-of-command-centr/databases-compressing-or-shrinking-the.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
