FM.SQL.FieldCount
-----------------

Queries number of fields.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [FM](component_FM.md) [FMSQL](component_FMSQL.md) | [5.1](newinversion51.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "FM.SQL.FieldCount"; SQLref ) 

**MBS**( **"FM.SQL.FieldCount";** /\* Queries number of fields. \*/  
**$SQLref**) /\* The reference number returned by [FM.SQL.Execute](FMSQLExecute.md) function. \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| SQLref | The reference number returned by [FM.SQL.Execute](FMSQLExecute.md) function. | $SQLRef |

### Result

Returns number or error.

### Description

Queries number of fields.  
### Examples

Query some values:

 Set Variable \[$sql ; Value:MBS ( "[FM.SQL.Execute](FMSQLExecute.md)"; ""; "select \* from Clients")\]  
If \[MBS ("IsError")\]  
 Show Custom Dialog \["SQL error"; $sql \]  
Else  
 Show Custom Dialog \["SQL result"; "got " &amp; MBS ( "[FM.SQL.RowCount](FMSQLRowCount.md)"; $sql ) &amp;" rows with each " &amp; MBS ( "FM.SQL.FieldCount"; $sql ) &amp; " …"\]  
 Set Variable \[$r ; Value:MBS ( "[FM.SQL.Release](FMSQLRelease.md)"; $sql )\]  
End If  
### See also

- [FM.SQL.CSV](FMSQLCSV.md)
- [FM.SQL.Execute](FMSQLExecute.md)
- [FM.SQL.Field](FMSQLField.md)
- [FM.SQL.FieldType](FMSQLFieldType.md)
- [FM.SQL.Release](FMSQLRelease.md)
- [FM.SQL.RowCount](FMSQLRowCount.md)
- [FM.SQL.Text](FMSQLText.md)
- [IsError](IsError.md)
- [SQL.Execute](SQLExecute.md)
- [SQL.FieldCount](SQLFieldCount.md)

### Example Databases

- [SQL in FileMaker/SQL Select Container](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20in%20FileMaker/SQL%20Select%20Container.shtml#1ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Advent calendar - Door 5 - Count your field and rows](https://www.mbsplugins.de/archive/2025-12-05/MBS_FileMaker_Advent_calendar_/monkeybreadsoftware_blog_filemaker)
- [Execute SQL in FileMaker and get back native field types](https://www.mbsplugins.de/archive/2015-04-18/Execute_SQL_in_FileMaker_and_g/monkeybreadsoftware_blog_filemaker)

This function is free to use.

Created 18th April 2015 , last changed 8th January 2017

  
[FM.SQL.Field](FMSQLField.md) - [FM.SQL.FieldType](FMSQLFieldType.md)

[HTML Version](FMSQLFieldCount.shtml)