list of primary keys - Sybase DB.

Rakesh Dhar 96 Reputation points
2021-11-09T18:43:04.727+00:00

Hello friends
.
I need the list of the primary keys for each table in a database . if a table has 1 key or 2 primary keys . it should show me in result set.
.
Please help me with the query . i am using the below "sp_pkeys". it is giving me correct and required result set .

exec sp_pkeys 'tableName'

but i need a Query .

My database is Sybase 15

Developer technologies | Transact-SQL
Developer technologies | Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
SQL Server | Other
{count} votes

2 answers

Sort by: Most helpful
  1. CathyJi-MSFT 22,406 Reputation points Microsoft External Staff
    2021-11-10T02:24:49.143+00:00

    Hi @Rakesh Dhar ,

    Welcome to MS Q&A forum.

    Your issue is related to Sybase DB. SQL server general and sql-server-transact-sql tags are talking about MS SQL server tech issues. Suggest you to create a new thread on Sybase DB forum. People there will give you a better help.

    https://stackoverflow.com/questions/tagged/sybase

    By the way, this a similar thread, please check if the solution from this thread could help you.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Tom Phillips 17,786 Reputation points
    2021-11-09T18:51:13.53+00:00

    This is a MS SQL Server forum, not Sybase. Although they are closely related, you would be better off using a Sybase forum.

    Please see:
    https://learn.microsoft.com/en-us/answers/questions/83218/query-to-find-list-of-all-primary-keys-and-check-i.html


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.