SQL.GetRecordsAsText
--------------------

Queries all records as text.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [SQL](component_SQL.md) | [5.3](newinversion53.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "SQL.GetRecordsAsText"; Command { ; FieldDelimiter; RowDelimiter } ) 

**MBS**( **"SQL.GetRecordsAsText";** /\* Queries all records as text. \*/  
**$Command**; /\* The command reference number gained with [SQL.NewCommand](SQLNewCommand.md). \*/   
**$FieldDelimiter**; /\* Optional; The delimiter for between fields.   
Default is a tab character. \*/   
**$RowDelimiter**) /\* Optional; The delimiter between records.   
Default is newline character. \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Command | The command reference number gained with [SQL.NewCommand](SQLNewCommand.md). | $Command |  |
| FieldDelimiter | The delimiter for between fields.    Default is a tab character. |  | Optional |
| RowDelimiter | The delimiter between records.    Default is newline character. |  | Optional |

### Result

Returns text or error.

### Description

Queries all records as text.  
Don't call [SQL.FetchNext](SQLFetchNext.md) before as this function will call it for you to loop over records.  
Converts all field content to text.  
If you just want one field, maybe you just select the required field with your select statement.  
  
Warning: If the text contains the delimiters for fields and rows, you may get strange results. You can of course substitute these in the SQL query. See the REPLACE() function in SQL.  
### Examples

Run and query result as text:

 #Create select and run it   
Set Variable \[$Command ; Value:MBS ("[SQL.NewCommand](SQLNewCommand.md)"; $Connection ; "SELECT \* FROM Test")\]  
\#Run it   
Set Variable \[$result ; Value:MBS ("[SQL.Execute](SQLExecute.md)"; $Command )\]  
If \[$result ≠ "OK"\]  
 Show Custom Dialog \["Error: " &amp; $result \]  
Else  
 Show Custom Dialog \["Inhalt"; MBS ("SQL.GetRecordsAsText"; $command )\]  
End If  
\#Cleanup   
Set Variable \[$result2 ; Value:MBS ("[SQL.FreeCommand](SQLFreeCommand.md)"; $Command )\]  
Query with Let statement:

 Let ( \[  
command = MBS ("[SQL.NewCommand](SQLNewCommand.md)"; 22001; "SELECT sqlite\_version();");  
status = MBS ("[SQL.Execute](SQLExecute.md)"; command);  
result = MBS ("SQL.GetRecordsAsText"; command);  
freed = MBS ("[SQL.FreeCommand](SQLFreeCommand.md)"; Command)  
\]; result)  
### See also

- [SQL.Execute](SQLExecute.md)
- [SQL.FetchNext](SQLFetchNext.md)
- [SQL.FreeCommand](SQLFreeCommand.md)
- [SQL.GetRecordsAsJSON](SQLGetRecordsAsJSON.md)
- [SQL.NewCommand](SQLNewCommand.md)

### Blog Entries

- [MBS FileMaker Plugin, version 5.3pr1](https://www.mbsplugins.de/archive/2015-08-26/MBS_FileMaker_Plugin_version_5/monkeybreadsoftware_blog_filemaker)

This function is free to use.

Created 10th August 2015 , last changed 15th December 2025

  
[SQL.GetRecordsAsJSON](SQLGetRecordsAsJSON.md) - [SQL.InsertOrUpdateRecords](SQLInsertOrUpdateRecords.md)

[HTML Version](SQLGetRecordsAsText.shtml)