SQLTables (ODBC)

When restricted to the current database, SQLTables executes the Transact-SQL procedure sp_tables to report table catalog data for Microsoft® SQL Server™.

The following table shows SQLTables parameter mapping for sp_tables stored procedure execution.

SQLTables parameter name sp_tables parameter name
CatalogName table_qualifier
SchemaName table_owner
TableName table_name
TableType table_type

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). SQLTables does not make use of sp_tables in this special case.

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 Server 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.

Example

// 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);

  

See Also

sp_tables


(c) 1988-98 Microsoft Corporation. All Rights Reserved.