How to get sybase table column name and its datatype and order by?

A.Goutam picture A.Goutam · Mar 9, 2015 · Viewed 43.3k times · Source

There are multiple table in my sybase database. I want to know the column name and datatype of a given table like (myOrder table). How can I do this? Below script I found on stackoverflow From a Sybase Database, how I can get table description ( field names and types)? . But this gives me exception syscolumns is ambiguous? The script is below that I used for this.

SELECT sc.* 
FROM syscolumns sc
INNER JOIN sysobjects so ON sc.id = so.id
WHERE so.name = 'my_table_name'

Answer

www picture www · Mar 9, 2015

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'