Search code examples
sybasesap-ase

How to get the name of the primary-key from a query


I am searching for a query that tell me the NAME of the primary-key of a table
example: In oracle I do this

select CONSTRAINT_NAME from user_constraints where table_name = 'CT' AND CONSTRAINT_TYPE ='P'

how to do that in sybase ?


Solution

  • Try this way:

    select name     
    from sysindexes
    where indid > 0
    and status2 & 2 = 2