> For the complete documentation index, see [llms.txt](https://docs.frends.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.frends.com/tasks/tasks/snowflake/executequery.md).

# ExecuteQuery

Task version: 2.0.0

Required Frends version: 5.5+

Required .NET version: 6.0

Compatible Agents: Crossplatform

Source code: <https://github.com/FrendsPlatform/Frends.Snowflake>

## Task Parameters

{% tabs %}
{% tab title="Input" %}

| Name                              | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| --------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 🗝ConnectionString : `String`     | <p>String that contains the necessary data to connect to the database.</p><p><br>Default: <code>-</code><br>Example: <code>account=testaccount-123;user=user;role=ACCOUNTADMIN;db=SHOP;schema=PUBLIC; authenticator=SNOWFLAKE\_JWT;private\_key\_file=C:/snow/rsa\_key.p8;private\_key\_pwd=MyStrongPassphrase</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| CommandType : `CommandTypes`      | <p>Specifies how a command string is interpreted.</p><p>ExecuteNonQuery: Executes an SQL statement, and returns the number of rows affected.</p><p>ExecuteReader: Executes the query, and returns an object that can iterate over the entire result set.</p><p>ExecuteScalar: Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.</p><p>Possible values:</p><ul><li><code>ExecuteNonQuery</code>: Specifies how a command string is interpreted.</li></ul><p>ExecuteNonQuery: Executes an SQL statement, and returns the number of rows affected.</p><p>ExecuteReader: Executes the query, and returns an object that can iterate over the entire result set.</p><p>ExecuteScalar: Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.</p><ul><li><code>ExecuteReader</code>: Specifies how a command string is interpreted.</li></ul><p>ExecuteNonQuery: Executes an SQL statement, and returns the number of rows affected.</p><p>ExecuteReader: Executes the query, and returns an object that can iterate over the entire result set.</p><p>ExecuteScalar: Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.</p><ul><li><code>ExecuteScalar</code>: Specifies how a command string is interpreted.</li></ul><p>ExecuteNonQuery: Executes an SQL statement, and returns the number of rows affected.</p><p>ExecuteReader: Executes the query, and returns an object that can iterate over the entire result set.</p><p>ExecuteScalar: Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.</p><p><br>Default: <code>-</code><br>Example: <code>-</code></p> |
| CommandText : `String`            | <p>text command to run against the data source.</p><p><br>Default: <code>-</code><br>Example: <code>SELECT \* FROM mytable</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| PrivateKeyFilePath : `String`     | <p>Full file path to the private key (.p8) used for Snowflake key pair authentication.</p><p><br>Default: <code>-</code><br>Example: <code>C:\keys\rsa\_key.p8</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| 🗝PrivateKeyPassphrase : `String` | <p>Optional passphrase for the private key file, if the key was generated with encryption.</p><p>Leave empty if the key file is unencrypted.</p><p><br>Default: <code>-</code><br>Example: <code>MySuperSecret123</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| {% endtab %}                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |

{% tab title="Options" %}

| Name                              | Description                                                                                                                                                                                                                                                                                                                                                                                      |
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| ThrowExceptionOnError : `Boolean` | <p>Gets or sets a value indicating whether an error should stop the Task and throw an exception.</p><p>If set to true, an exception will be thrown when an error occurs. If set to false, Task will try to continue and the error message will be added into Result.ErrorMessage and Result.Success will be set to false.</p><p><br>Default: <code>True</code><br>Example: <code>true</code></p> |
| TimeOut : `Int32`                 | <p>Gets or sets the wait time (in seconds) before terminating the attempt to execute a command and generating an error.</p><p><br>Default: <code>30</code><br>Example: <code>30</code></p>                                                                                                                                                                                                       |
| {% endtab %}                      |                                                                                                                                                                                                                                                                                                                                                                                                  |
| {% endtabs %}                     |                                                                                                                                                                                                                                                                                                                                                                                                  |

## Task Result

| Name                      | Description                                                                                                                                                                                                                                                             |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Success : `Boolean`       | <p>Gets a value indicating whether the Task was executed successfully.<br>Example: <code>true</code></p>                                                                                                                                                                |
| RecordsAffected : `Int32` | <p>Records affected. Some statements will return -1.<br>Example: <code>100</code></p>                                                                                                                                                                                   |
| ErrorMessage : `Object`   | <p>Error message. This value is generated when an exception occurs and Options.ThrowErrorOnFailure = false.<br>Example: <code>Table 'NOTABLE' does not exist or not authorized...</code></p>                                                                            |
| Data : `Object`           | <p>Procedure's result as JToken.<br>Example: <code>Examples using SELECT query Input.ExecuteType = ExecuteReader: \[{"NAME": "Jane","AGE": 94},{"NAME": "Eve","AGE": 53}], Input.ExecuteType = NonQuery: null, Input.ExecuteType = Scalar: {"Value": "Jane"}</code></p> |

## Task Changelog

Changelog for Task Frends.Snowflake.ExecuteQuery.

### \[2.0.0] - 2025-09-03

#### Changed

* \[Breaking] Result now returns a dynamic JToken instead of DataTable when using ExecuteReader mode.
* Added support for CancellationToken, thus enabling query cancellation.

### \[1.2.0] - 2025-09-03

#### Added

* Added support for Snowflake key pair authentication: Input.PrivateKeyFilePath: full path to the .p8 private key file. Input.PrivateKeyPassphrase: optional passphrase for encrypted private keys.

### \[1.1.0] - 2025-02-12

#### Changed

* Update: Snowflake.Data 2.1.5 -> 4.3.0 MSTest.TestAdapter 3.8.0 -> 3.8.3 MSTest.TestFramework 3.8.0 -> 3.8.3

### \[1.0.0] - 2024-01-08

#### Added

* Initial implementation


---

# 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 dynamically by asking a question.

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

```
GET https://docs.frends.com/tasks/tasks/snowflake/executequery.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
