Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Best way to determine Primary Key and Identity column
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
00636928
Message ID:
00636930
Vues:
16
>Are there fast/efficient calls to determine the primary key columns and/or the identity column for a table?
>
>The best I can find for the PK is to call SP_HELPINDEX and then look through the result set to find the phrase "PRIMARY KEY" in the description. The index_keys column for that row contains the column(s) that make up the PK.
>
>As for the IDENTITY column, I call OBJECTPROPERTY() to determine if the table has one, then loop through the columns calling COLUMNPROPERTY() to figure out which one it is.
>
>Seems to me there would be a better way.
>
>Thanks in advance,
>Mike Yeager

You can use sp_pkeys() to get info about primart keys.
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform