# Query data type
> Version: _Available or changed with runtime version 1.0._
Enables you to retrieve data from multiple tables and combine the data in single dataset.
## Static methods
The following methods are available on the Query data type.
Method name|Description
SaveAsCsv(Integer, Text [, Integer] [, Text])<query-saveascsv-integer-string-integer-string-method>|Saves the resulting data set of a query as a comma-separated values (CSV) file.
SaveAsCsv(Integer, OutStream [, Integer] [, Text])<query-saveascsv-integer-outstream-integer-string-method>|Saves the resulting data set of a query as a comma separated values (CSV) file.
SaveAsJson(Integer, OutStream)<query-saveasjson-method>|Saves the resulting data set of a query as an .json file.
SaveAsXml(Integer, Text)<query-saveasxml-integer-string-method>|Saves the resulting data set of a query as an .xml file.
query-saveasxml-integer-outstream-method|Saves the resulting data set of a query as an .xml file.
## Instance methods
The following methods are available on instances of the Query data type.
Method name|Description
queryinstance-close-method|Closes a query data set and returns the query instance to the initialized state. The following code shows the syntax of the CLOSE method. Query is a variable of the Query data type that specifies the query object.
ColumnCaption(Any)<queryinstance-columncaption-method>|Returns the current caption of a query column as a text string.
ColumnName(Any)<queryinstance-columnname-method>|Returns the name of a query column as a text string.
ColumnNo(Any)<queryinstance-columnno-method>|Returns the ID that is assigned to a query column in the query definition.
GetFilter(Any)<queryinstance-getfilter-method>|Returns the filters that are set on the field of a specified column in the query. The following code shows the syntax of the GETFILTER method. Query is a variable of the Query data type that specifies the query object.
queryinstance-getfilters-method|Returns the filters that are applied to all columns in the query. The following code shows the syntax of the GETFILTERS method. Query is a variable of the Query data type that specifies the query object.
queryinstance-open-method|Runs a query object and generates a data set that can be read. The following code shows the syntax of the OPEN method. Query is a variable of the Query data type that specifies the query object.
queryinstance-read-method|Reads data from a row in the resulting data set of a query.
SaveAsCsv(Text [, Integer] [, Text])<queryinstance-saveascsv-string-integer-string-method>|Saves the resulting data set of a query as comma separated values (CSV)
SaveAsCsv(OutStream [, Integer] [, Text])<queryinstance-saveascsv-outstream-integer-string-method>|Saves the resulting data set of a query as comma separated values (CSV)
SaveAsJson(OutStream)<queryinstance-saveasjson-method>|Saves the resulting data set of a query as Json
SaveAsXml(Text)<queryinstance-saveasxml-string-method>|Saves the resulting data set of a query as XML
queryinstance-saveasxml-outstream-method|Saves the resulting data set of a query as XML
queryinstance-securityfiltering-method|Gets or sets how security filters are applied to the query.
SetFilter(Any, Text [, Any,...])<queryinstance-setfilter-method>|Sets a filter on a column of a query to limit the records in the resulting data set of a query.
SetRange(Any [, Any] [, Any])<queryinstance-setrange-method>|Sets a filter on a range of values on a column of a query data set.
TopNumberOfRows([Integer])<queryinstance-topnumberofrows-method>|Specifies the maximum number of rows to include in the resulting data set of a query.
## Related information
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/query-data-type, 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/query-data-type/
