SQLTables can be executed on a static server cursor. An attempt to execute SQLTables on an updatable (dynamic or keyset) cursor will return SQL_SUCCESS_WITH_INFO indicating that the cursor type has been changed.

SQLTables reports tables from all databases when the CatalogName parameter is SQL_ALL_CATALOGS and all other parameters contain default values (NULL pointers).

To report available catalogs, schemas, and table types, SQLTables makes special use of empty strings (zero-length byte pointers). Empty strings are not default values (NULL pointers).

The SQL Native Client ODBC driver supports reporting information for tables on linked servers by accepting a two-part name for the CatalogName parameter: Linked_Server_Name.Catalog_Name.

SQLTables returns information about any tables whose names match TableName and are owned by the current user.

// Get a list of all tables in the current database.
SQLTables(hstmt, NULL, 0, NULL, 0, NULL, 0, NULL,0);

// Get a list of all tables in all databases.
SQLTables(hstmt, (SQLCHAR*) "%", SQL_NTS, NULL, 0, NULL, 0, NULL,0);

// Get a list of databases on the current connection's server.
SQLTables(hstmt, (SQLCHAR*) "%", SQL_NTS, (SQLCHAR*)"", 0, (SQLCHAR*)"",
    0, NULL, 0);

Community Additions