question

RakeshDhar-0664 avatar image
0 Votes"
RakeshDhar-0664 asked Cathyji-msft commented

list of primary keys - Sybase DB.

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-generalsql-server-transact-sql
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @RakeshDhar-0664,

We have not received a response from you. Did the reply(s) could help you?

0 Votes 0 ·
TomPhillips-1744 avatar image
0 Votes"
TomPhillips-1744 answered ErlandSommarskog commented

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://docs.microsoft.com/en-us/answers/questions/83218/query-to-find-list-of-all-primary-keys-and-check-i.html

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

These days I would not call them "closely" related. And, particularly, Microsoft has completely redesigned how metadata is stored, so queries for SQL Server will not run on Sybase.

What you can do is:

EXEC sp_helptext sp_pkeys

to look at the code, and use that to craft your query.

0 Votes 0 ·
Cathyji-msft avatar image
0 Votes"
Cathyji-msft answered

Hi @RakeshDhar-0664,

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.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.