How to query constraints in Sybase

I have following query works for SQL Server. Can someone help me translate it to Sybase?
USE database_name;
SCHEMA_NAME(schema_id) AS SchemaName,
OBJECT_NAME(parent_object_id) AS TableName,
type_desc AS ConstraintType
FROM sys.objects
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

change 'sys.objects' to 'sysobjects'

also then look at the fieldnames, here:

and other system tables are also documented there.

ps: don't have access to Sybase myself I'm afraid
This may help (untested)
SELECT  constraint_name
      ,  table_name
      , column_name
FROM sysobjects o1
INNER JOIN sysconstraints c
        ON = c.constrid
INNER JOIN sysobjects o2
        ON = c.tableid
INNER JOIN syscolumns col
        ON = c.colid

Open in new window

Joe WoodhousePrincipal ConsultantCommented:
In fact all you need to do is look at Sybase's source code for their system stored procedures. They could easily have hidden or encrypted it and deliberately chose not to, so we could see how to write these sorts of queries.

The text of sp_helpconstraint in the sybsystemprocs database has everything you need.

It's a bit more complicated than you think because check constraints, RI constraints, and key constraints all work differently. If you want to see all of them you'll need some clever code - remember a unique index acts as a unique constraint but is not stored as a constraint...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.