How to get sybase table column name and its datatype and order by?
To extract types I am using such query:
SELECT syscolumns.name, systypes.name FROM sysobjects
JOIN syscolumns ON sysobjects.id = syscolumns.id
JOIN systypes ON systypes.type = syscolumns.type AND systypes.usertype = syscolumns.usertype
WHERE sysobjects.name LIKE 'my_table'
You can use built-in procedure sp_columns. It will return all the table metadata including column name, data type, column length etc. for a given table.
sp_columns table_name