I was trying to find the primary keys from an SQLServer database through the ODBC interface. Funnily enough, the odbc_primarykeys function doesn't work with SQLServer (at least not my implementation of it). Fortunately, the sp_keys query is passed through and the answer returned. This code works (providing you know which database you're dealing with, which is a whole 'nother story).
// If this is SQLServer, we need to do a special operation to get the
// primary keys.
//
// Looks like the implementers of the ODBC interface just blew this
// one off, since the database has a query to return the info and the
// info even comes back with the same column names.
if ($DBType == "SQLServer")
$KeySel = odbc_exec($DBConn, "sp_pkeys ".$TableName);
// Otherwise, ask the database through ODBC for the primary key
// names.
else $KeySel = odbc_primarykeys($DBConn, $DatabaseName,
$DatabaseUser, $TableName);
while ($KeySel && ($KeyRec = odbc_fetch_array($KeySel)))
$KeyCol[$KeyRec["KEY_SEQ"]] = $KeyRec["COLUMN_NAME"];