Reputation: 885
What SQL can I use to get the type of a column in Sybase ASE?
Upvotes: 0
Views: 264
Reputation: 46
Within any database you could use special stored procedure
sp_columns '<tableName>', null, null, '<colName>'
and of course, to display all columns with extensive info about them for given table:
sp_columns '<tableName>'
Upvotes: 1
Reputation: 885
Given a table named "fruit" and a column named "color":
select obj.name as "table", col.name as "column", type.name as "type"
from sysobjects obj
join syscolumns col on obj.id=col.id
join systypes type on col.type=type.type and col.usertype = type.usertype
where obj.type = "U" -- means 'U'ser table
and user_name(obj.uid) = 'dbo' -- or whatever the user is who owns/created the table
and obj.name = 'fruit'
and col.name = 'color'
Upvotes: 0