# 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

![](/files/MrKegP7bKYlEplZca2eH)

### Choose A Snapshot

![](/files/eWpWE4T56PZzXyHnC5gt)

### Select a Table and Columns for the SQL

![](/files/uDQIrhY3rriSbaXYbL8B)

### Open the Preview and Set a Filter

![](/files/2AlNN5vZCoOYPMpQxMRr)

### View the Generated SQL

![](/files/GTK7haiGbpGt0n1RxZqo)


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.capstorm.com/frequently-asked-questions/how-do-copystorm-archives-work/how-to-generate-sql-for-an-archive.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
