exec
(Not recommended) Execute SQL statement and open cursor
The exec function is not recommended. For SQL statements that return
      data, use the fetch function or the select function instead. For other SQL statements, use the execute function
      instead. For details, see Version History.
The scrollable cursor functionality has no replacement.
Syntax
Description
curs = exec(conn,sqlquery,Name,Value)'MaxRows',10 limits the number of rows to return to 10 before SQL
          query execution.
Examples
Input Arguments
Name-Value Arguments
Output Arguments
Limitations
The name-value pair argument 'MaxRows' has these limitations:
- If you are using Microsoft Access®, the native ODBC interface is not supported. 
- Not all database drivers support setting the maximum number of rows before query execution. For an unsupported driver, modify your SQL query to limit the maximum number of rows to return. The SQL syntax varies with the driver. For details, consult the driver documentation. 
Tips
- The order of records in your database does not remain constant. Sort data using the SQL - ORDER BYcommand in your- sqlquerystatement.
- For Microsoft Excel®, tables in - sqlqueryare Excel worksheets. By default, some worksheet names include a- $symbol. To select data from a worksheet with this name format, use an SQL statement of the form- SELECT * FROM "Sheet1$" (or- 'Sheet1$').
- Before you modify database tables, ensure that the database is not open for editing. If you try to edit the database while it is open, you receive this MATLAB error: - [Vendor][ODBC Driver] The database engine could not lock table 'TableName' because it is already in use by another person or process. 
- The PostgreSQL database management system supports multidimensional fields, but SQL - SELECTstatements fail when retrieving these fields unless you specify an index.
- Some databases require that you include a symbol, such as - #, before and after a date in a query, as follows:- curs = exec(conn,'SELECT * FROM mydb WHERE mydate > #03/05/2005#') 
Alternative Functionality
App
The exec function executes SQL statements using the command line.
        To execute SQL statements interactively, use the Database
          Explorer app.