# ExecuteQueryToFile

Required Frends version: 5.5+

Required .NET version: 6.0

Compatible Agents: Crossplatform

Source code: <https://github.com/FrendsPlatform/Frends.MicrosoftSQL/tree/main/Frends.MicrosoftSQL.ExecuteQueryToFile>

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

| Name                               | Description                                                                                                                                                                                                                                                         |
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Query : `String`                   | <p>Query to execute.</p><p><br>Default: <code>-</code><br>Example: <code>SELECT \* FROM table</code></p>                                                                                                                                                            |
| QueryParameters : `SqlParameter[]` | <p>Query parameters.</p><p><br>Default: <code>-</code><br>Example: <code>\[ { Name = test, Value = test\_value, SqlDataType = SqlDataTypes.Auto } ]</code></p>                                                                                                      |
| 🗝ConnectionString : `String`      | <p>Database connection string.</p><p><br>Default: <code>"Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;"</code><br>Example: <code>Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;</code></p> |
| OutputFilePath : `String`          | <p>Output file path.</p><p><br>Default: <code>-</code><br>Example: <code>C:\path\tp\file.csv</code></p>                                                                                                                                                             |
| {% endtab %}                       |                                                                                                                                                                                                                                                                     |

{% tab title="Parameter: Options" %}

| Name                          | Description                                                                                                                                                                                                                                        |
| ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| TimeoutSeconds : `Int32`      | <p>Operation timeout (seconds).</p><p><br>Default: <code>30</code><br>Example: <code>30</code></p>                                                                                                                                                 |
| ReturnFormat : `ReturnFormat` | <p>Determines in what format the query is written.</p><p>Possible values:</p><ul><li><code>CSV</code>:</li></ul><p>Determines in what format the query is written.</p><p><br>Default: <code>0</code><br>Example: <code>ReturnFormat.CSV</code></p> |
| CsvOptions : `CsvOptions`     | <p>Csv options.</p><p><br>Default: <code>-</code><br>Example: <code>-</code></p>                                                                                                                                                                   |
| {% endtab %}                  |                                                                                                                                                                                                                                                    |

{% tab title="Result: Result" %}

| Name                     | Description                                                   |
| ------------------------ | ------------------------------------------------------------- |
| EntriesWritten : `Int32` | <p>Amount of entries written.<br>Example: <code>2</code></p>  |
| Path : `String`          | <p>Path to the file.<br>Example: <code>C:\test.csv</code></p> |
| FileName : `String`      | <p>Name of the file.<br>Example: <code>test.csv</code></p>    |
| {% endtab %}             |                                                               |

{% tab title="Changelog" %}

## Changelog

### \[2.3.0] - 2026-01-30

#### Fixed

* Fixed an issue that was causing problems with Frends processes' cleanup and assembly unloading.

### \[2.2.0] - 2026-01-22

#### Changed

* Improve execution of async methods.

### \[2.1.0] - 2024-12-16

#### Added

* Added Microsoft.SqlServer.Types dependency so that SqlGeography and SqlGeometry typed objects can be handled.

### \[2.0.0] - 2024-08-05

#### Changed

* \[Breaking] The task now uses Microsoft.Data.SqlClient instead of System.Data.SqlClient.

### \[1.0.1] - 2024-02-12

#### Fixed

* Fixed handling of null query parameters by changing the parameter value to DBNull.Value.

### \[1.0.0] - 2024-02-07

#### Changed

* Initial implementation
  {% endtab %}
  {% endtabs %}
