views:

1355

answers:

1

I have a list of columns a co-worker has given to me, but these columns reside in different tables in the DB. Is there some kind of tool in Sybase where I can query the table a column belongs to?

(I've tried Google-ing for this kind of tool, but no luck so far)

+2  A: 

syscolumns holds column metadata.

select * from syscolumns where name = ;

The id column in syscolumns is the id of the column's table, in sysobjects;

select b.name as tablename, a.name as columnname
from syscolumns a join systables b on (a.id = b.id) 
where b.type='U' and b.name = 'foo';

gets all columns for the table named 'foo'. The type = 'U' limits it to user tables.

select b.name as tablename, a.name as columnname
from syscolumns a join systables b on (a.id = b.id) 
where b.type='U' and a.name = 'foo';

gets all columns named 'foo'.

tpdi
Thanks! Yes this actually helps. I also found a diagram of Sybase ASE that visualizes your answer: http://download.sybase.com/pdfdocs/asg1250e/poster.pdf
Jose Chavez