I have this code:
select a.id as tableid,
a.name as tableName,
b.name as columnName,
b.status as columnStatus,
b.type as columnType
from sysobjects a
LEFT JOIN syscolumns b
ON a.id = b.id
WHERE a.name = 'table_name'
Now, the columType shows numbers. I want to get the name of the columnType, which resides in column 'name' in table 'systypes'. How do I do that? Simple LEFT JOIN will result in duplicate rows.
I've seen in Sybase 15.0 and this is the code that you have to use:
select o.id [tableid], o.name [tableName], c.name [columnName], c.status [columnStatus], t.name [columnType] from sysobjects o
inner join syscolumns c on c.id = o.id
inner join systypes t on t.usertype = c.usertype
where o.type = 'U' and o.name in ('tablename')