Matrix.NewWithSQL
-----------------

Execute the SQL Statement against a FileMaker database.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Matrix](component_Matrix.md) | [9.2](newinversion92.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Matrix.NewWithSQL"; FileName; SQL Statement { ; Params... } ) 

**MBS**( **"Matrix.NewWithSQL";** /\* Execute the SQL Statement against a FileMaker database. \*/  
**$FileName**; /\* The target database name. Can be empty to not limit query to one database.e.g. "" \*/   
**$SQL Statement**; /\* SQL Statement as a Text string \*/   
**$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 |
|---|---|---|---|
| FileName | The target database name. Can be empty to not limit query to one database. | "" |  |
| SQL Statement | SQL Statement as a Text string |  |  |
| 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 matrix reference number or error.

### Description

Execute the SQL Statement against a FileMaker database.   
Returns a matrix reference number, so you can use functions like [Matrix.Height](MatrixHeight.md), [Matrix.Width](MatrixWidth.md), [Matrix.GetValue](MatrixGetValue.md) and [Matrix.DataType](MatrixDataType.md) to query result.   
Don't forget to use [Matrix.Release](MatrixRelease.md) to release the result from memory when you are done with it.  
  
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.  
### See also

- [Matrix.Add](MatrixAdd.md)
- [Matrix.AddRow](MatrixAddRow.md)
- [Matrix.CSV](MatrixCSV.md)
- [Matrix.DataType](MatrixDataType.md)
- [Matrix.GetColumn](MatrixGetColumn.md)
- [Matrix.GetRow](MatrixGetRow.md)
- [Matrix.Height](MatrixHeight.md)
- [Matrix.InsertOrUpdateRecords](MatrixInsertOrUpdateRecords.md)
- [Matrix.Release](MatrixRelease.md)
- [Matrix.Width](MatrixWidth.md)

### Example Databases

- [SQL in FileMaker/Insert or Update Tests](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20in%20FileMaker/Insert%20or%20Update%20Tests.shtml#6ScriptAnchor_)
- [SQL to other databases/SQLite fun](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20to%20other%20databases/SQLite%20fun.shtml#10ScriptAnchor_)

### Blog Entries

- [Data structures in MBS Plugin](https://www.mbsplugins.de/archive/2023-11-27/Data_structures_in_MBS_Plugin/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 8th April 2019 , last changed 7th April 2022

  
[Matrix.New](MatrixNew.md) - [Matrix.Release](MatrixRelease.md)

[HTML Version](MatrixNewWithSQL.shtml)