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

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,757 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,554 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Tom Phillips 17,716 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


  2. CathyJi-MSFT 21,096 Reputation points Microsoft Vendor
    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