**Source URL:** https://general.veevavault.dev/clinical/vault-toolbox/vs-code-extension/guides/vql-editor

# Using the VQL Editor

Vault Toolbox includes a VQL Editor for running read-only Vault queries directly within Visual Studio Code. The VQL Editor features syntax highlighting, a Query Builder, saved queries, query history, query formatting, and CSV export.

This guide outlines how to write and run queries in the editor and build queries visually with the Query Builder. Learn more about [sending VQL queries](/clinical/vql/getting-started/structuring-sending-queries/).

<Aside>
VQL is read-only and cannot modify data. Your user account must have the appropriate object and field permissions to query records.
</Aside>

## Running Queries

To run a query:

<Steps>
1.  Select the **Vault Toolbox** icon in the lefthand panel.
2.  Select the **VQL Editor** (<Icon name="ph:magnifying-glass" />) tab.
3.  Type a VQL statement in the editor, or select a query from the saved-queries or history dropdown. For example, `SELECT id FROM documents`.
4.  Optional: Click (<Icon name="ph:code-block" />) **Format Query** to reformat the query for readability.
5.  Click **Run VQL**, or press `Cmd+Enter` (macOS) or `Ctrl+Enter` (Windows/Linux).
    
    <ThemeImage srcLight="/images/toolbox/vscode-extension/vql_editor_light.png" srcDark="/images/toolbox/vscode-extension/vql_editor_dark.png" alt="Vault Toolbox Visual Studio Code Extension VQL Editor Results" />
</Steps>

 

<Aside>
If no environment is connected, Vault Toolbox prompts you to connect one first. See [Managing Environments](/clinical/vault-toolbox/vs-code-extension/guides/managing-environments) to learn how to connect an environment.
</Aside>

Results display in a table below the editor. Use **‹ Prev** and **Next ›** to page through results. A range label shows how many of the total rows are currently displayed. Click **JSON** next to **Table** to view the raw response instead of a grid.

## Opening in an Editor Tab

Click <Icon name="ph:arrow-square-out" /> next to the *VQL Editor* title to open the editor in a full editor tab within Visual Studio Code instead of the sidebar panel. The query, results, and view mode stay in sync between the sidebar and the full editor tab.

## Saving and Reusing Queries

Click (<Icon name="ph:floppy-disk" />) **Save Query** to save the current query under a name. Open the **Saved** dropdown to load or delete a saved query, or filter the list by name. Open the **History** dropdown to re-load one of your recent queries, or clear your history.

## Exporting Results

Click (<Icon name="ph:download-simple" />) **Download CSV** in the editor header to export all pages of the query results to a CSV file. If the results exceed 10,000, Vault Toolbox prompts you with a warning dialog prior to downloading.

## Building Queries Visually

The Query Builder helps you construct a VQL statement without writing it by hand. Pick a query target, choose which fields to select, add filter conditions, and optionally set a page size, then insert the result into the editor.

To build a query visually:

<Steps>
1.  From the VQL Editor, expand the **Query Builder** and select a query **Target**. For example, *Product*.
2.  Select **Fields**. Picking a field on the object itself adds it directly. Picking a field through a relationship adds either a dotted `relationship.field` expression or an inbound subquery, depending on the relationship direction.
3.  Optional: Click **\+ Add filter** to add a `WHERE` clause. Select a **Field**, an operator valid for that field's type (`=`, `!=`, `<`, `>`, `<=`, `>=`, `CONTAINS`, `LIKE`), and a **Value**. Use the match mode to combine multiple filter rows with **AND** or **OR**.
4.  Optional: Enter a **Page Size**. Leave blank to use the [default page size](/vql/references/system-limits-performance/page-size-specifications/#Number_of_Records_Returned).
5.  Click **Build Query in Editor**.
    
    <ThemeImage srcLight="/images/toolbox/vscode-extension/vql_editor_query_builder_light.png" srcDark="/images/toolbox/vscode-extension/vql_editor_query_builder_dark.png" alt="Vault Toolbox Visual Studio Code Extension VQL Editor Query Builder" />
</Steps>

The generated query does not run automatically. Review and edit it in the editor, then click **Run VQL** to send it.

---

**Previous:** [Managing Environments](/clinical/vault-toolbox/vs-code-extension/guides/managing-environments)  
**Next:** [Working with Vault Java SDK Code](/clinical/vault-toolbox/vs-code-extension/guides/vault-java-sdk-code)