# Query.SaveAsCsv(Text [, Integer] [, Text]) Method
> Version: _Available or changed with runtime version 1.0._
Saves the resulting data set of a query as comma separated values (CSV)
> NOTE
> This method is supported only in Business Central on-premises.
## Syntax
```al
[Ok := ]  Query.SaveAsCsv(FileName: Text [, Format: Integer] [, FormatArgument: Text])
```
## Parameters
Query
Type: query-data-type
An instance of the query-data-type data type.
FileName
Type: ../text/text-data-type
The path and name of the file that you want to save the query to.
*[Optional] Format*
Type: ../integer/integer-data-type
Specifies whether the columns of the resulting data set are at fixed positions in the CSV file or separated only by a delimiter.
*[Optional] FormatArgument*
Type: ../text/text-data-type
You set the FormatArgument parameter based on the setting of the Format parameter. If the Format parameter is set to 0, then the FormatArgument parameter specifies the starting position of each column in the data set. The value is a comma separated string of integers that includes an integer for every column. In a CSV file, each line is evenly divided into positions for holding characters. The first integer corresponds to the starting position of the first column, the second integer corresponds to the starting position of the second column, and so on.
## Return Value
*[Optional] Ok*
Type: ../boolean/boolean-data-type
true if the SaveAsCsv succeeded, otherwise false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.
## Related information
query-data-type
Get Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-overview>

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/query/queryinstance-saveascsv-string-integer-string-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/query/queryinstance-saveascsv-string-integer-string-method/
