SQLPrimaryKeys (ODBC)

SQLPrimaryKeys uses the catalog stored procedure sp_pkeys to report primary key participants from a table. Though a table may have a column or columns that can serve as unique row identifiers, tables created without a PRIMARY KEY constraint return an empty result set to SQLPrimaryKeys. The ODBC function SQLSpecialColumns reports row identifier candidates for tables without primary keys.

The following table shows SQLPrimaryKeys parameter mapping for sp_pkeys stored procedure execution.

SQLPrimaryKeys parameter name sp_pkeys parameter name
CatalogName table_qualifier
SchemaName table_owner
TableName table_name

SQLPrimaryKeys returns SQL_SUCCESS whether or not values exist for CatalogName, SchemaName, or TableName parameters. SQLFetch returns SQL_NO_DATA when invalid values are used in these parameters.

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

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

See Also
sp_pkeys SQLSpecialColumns

  


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