> For the complete documentation index, see [llms.txt](https://learn.capstorm.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learn.capstorm.com/frequently-asked-questions/how-do-copystorm-archives-work/how-to-generate-sql-for-an-archive.md).

# How to Generate SQL for a Snapshot

The CopyStorm Snapshot subsystem stores record data in database XML column types and many database professionals may not be familiar with how to write SQL queries to read snapshot data. Though we do not expect many people to write their own SQL queries against CopyStorm snapshots, we have include a query generator to help a programmer to get started.

The basic procedure is:

* Open the Snapshot Explore for the snapshot you want to query.
* Select a table and the columns you want in the query.
* Go to the Preview stage and click on the “Generate Query” button. The system will open a dialog which shows the SQL that matches your query. Copy and Paste the generated SQL and you will have a good starting point for your own query.

The generated SQL queries provided by CopyStorm should help you avoid a deep dive into a study of how to build an XML column query for your specific database type.

To practice this procedure see:

* [Snapshot Explorer](/reference/archive-tab/explore-archive.md)
* [How to Export Data from a Snapshot](/frequently-asked-questions/how-do-copystorm-archives-work/how-to-export-data-from-an-archive.md)
* The [How to Setup a Custom Snapshot](/frequently-asked-questions/how-do-copystorm-archives-work/how-to-setup-a-custom-archive.md) tutorial
* The reference page [Column Expression Filter Rule](/reference/archive-tab/archive-policy-editor/policy-filter-rules/column-expression-filter-rule.md).

### Launch the Snapshot Explorer from the Snapshot Tab

![](https://4057376488-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsbSqfKw3vSfr8qwXao4j%2Fuploads%2Fgit-blob-d16d8833143790629ee94fc83a062e69818f8215%2F8a08b087-Open-Explorer.png?alt=media)

### Choose A Snapshot

![](https://4057376488-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsbSqfKw3vSfr8qwXao4j%2Fuploads%2Fgit-blob-b9a84e604057d9dcc22b75f8f636ce04b75e0d4a%2Fa81f43c0-Choose-Snapshot.png?alt=media)

### Select a Table and Columns for the SQL

![](https://4057376488-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsbSqfKw3vSfr8qwXao4j%2Fuploads%2Fgit-blob-f297ea47d24e33eb13b26a3aa6a771f00c622604%2F8e99dc89-Select-Table-Fields.png?alt=media)

### Open the Preview and Set a Filter

![](https://4057376488-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsbSqfKw3vSfr8qwXao4j%2Fuploads%2Fgit-blob-5dacd40695f1e0fac63b44bb626757e4f114384a%2F46d214b9-Record-Filter-1.png?alt=media)

### View the Generated SQL

![](https://4057376488-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsbSqfKw3vSfr8qwXao4j%2Fuploads%2Fgit-blob-9a801a0bdd9fe66bdd08a7ce785e3f39e5f0b138%2F8d662edc-View-SQL.png?alt=media)
