Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best way to determine Primary Key and Identity column
Message
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
00636928
Message ID:
00636930
Views:
17
>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--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform