ListDialog.AddSQL
-----------------

Adds items via SQL statement.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [ListDialog](component_ListDialog.md) | [5.1](newinversion51.md) | ✅ Yes | ✅ Yes | ❌ No | ❌ No | ✅ Yes |

MBS( "ListDialog.AddSQL"; SQL Statement; FileName { ; Params... } ) 

**MBS**( **"ListDialog.AddSQL";** /\* Adds items via SQL statement. \*/  
**$SQL Statement**; /\* SQL Statement as a Text string \*/   
**$FileName**; /\* The target database name. Can be empty to not limit query to one database.e.g. "" \*/   
**$Params...**) /\* Optional; Optional, pass here parameters. One parameter to this function for each parameter you want to pass to the SQL statement.e.g. 123 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| SQL Statement | SQL Statement as a Text string |  |  |
| FileName | The target database name. Can be empty to not limit query to one database. | "" |  |
| Params... | Optional, pass here parameters. One parameter to this function for each parameter you want to pass to the SQL statement. | 123 | Optional |

### Result

Returns number of items added or error.

### Description

Adds items via SQL statement.  
First field from SQL result is used as text, second as tag and third as header flag.  
Tag and header columns are optional.  
  
This function takes variable number of parameters. Pass as much parameters as needed separated by the semicolon in FileMaker.  
Please repeat Params parameter as often as you need.  
### Examples

Add items:

 MBS ("ListDialog.AddSQL"; "select Text, Tag, Header from Liste")  
Add value list entries for texts and tags:

 Set Variable \[ $result ; Value: MBS ("ListDialog.AddSQL"; "SELECT DISTINCT ValueList2, ValueList1 FROM Kontakte WHERE Length(ValueList2) &gt; 0 ORDER BY ValueList2 ASC")\]  
### Release notes

- **Version 15.2**
    - Fixed an issue with [ListDialog.AddSQL](https://www.mbsplugins.eu/ListDialogAddSQL.shtml) function where filename parameter was ignored if no other parameters followed.

### Blog Entries

- [MBS FileMaker Plugin, version 15.2pr4](https://www.mbsplugins.de/archive/2025-04-16/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 5.1 for OS X/Windows](https://www.mbsplugins.de/archive/2015-05-19/MBS_FileMaker_Plugin_51_for_OS/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 5.1pr2](https://www.mbsplugins.de/archive/2015-03-23/MBS_FileMaker_Plugin_version_5/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 21st March 2015 , last changed 13th June 2025

  
[ListDialog.AddItemsToList](ListDialogAddItemsToList.md) - [ListDialog.ClearColumnHeaders](ListDialogClearColumnHeaders.md)

[HTML Version](ListDialogAddSQL.shtml)