> ## Documentation Index
> Fetch the complete documentation index at: https://docs.omni.co/llms.txt
> Use this file to discover all available pages before exploring further.

# sql_preamble

> Runs a setup query before executing SQL statements against a model.

This parameter supports [Mustache rendering](/visualize-present/mustache-reference), allowing you to dynamically inject values such as [user attributes](/administration/users/attributes).

This parameter is useful for setting database session properties or configurations that need to be applied before queries run, particularly when those configurations need to vary based on user-specific attributes. All dialects are supported.

## Syntax

```yaml theme={null}
sql_preamble: <sql_statement>
```

## Properties

<ParamField path="sql_preamble" type="string">
  A SQL statement to execute as a setup query before running SQL statements in the connection. Supports Mustache syntax for dynamic value injection, such as user attributes via `{{ omni_attributes.<attribute_name> }}`. All dialects are supported.
</ParamField>

## Examples

Omni automatically quotes user attributes when files are saved in the model IDE, meaning that the attribute value is always treated as a string. For example, even if the value of `{{ omni_attributes.special_prop_name }}` is numeric - like `5` or `102` - it'll be treated as if it were `"5"` or `"102"`:

```yaml title="Set a database property using a custom user attribute" theme={null}
sql_preamble: SET some_database_prop = {{ omni_attributes.special_prop_name }}
```

If you're using Snowflake or Databricks and you need to set a non-string property, you can use `IDENTIFIER` to convert the quoted string:

```yaml title="Snowflake and Databricks - Use IDENTIFIER to convert the attribute value type" theme={null}
sql_preamble: SET some_database_prop = IDENTIFIER({{ omni_attributes.special_prop_name }})
```
