How to get column definition of a table from systables

Posted on 2010-01-12
Medium Priority
Last Modified: 2012-05-08
I want to get column definition of a table through system tables but I am finding it hard.  I want to know datatype,length and if it allows null values are not.

Looks like one type in syscolumns is mapping to multiple columns in systypes. I am not sure how to get uniq type any idea( I tried user_type but didn't work)
Question by:koppcha
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 13

Expert Comment

ID: 26299019
You should use usertype for only user defined datatypes and type for all others. If you are trying to write a query for that, user defined datatypes have always a type number higher than 100. So you can join with systypes two times one for usertype < 100 and the other for usertype > 100. Former join will be based on type and the latter join will be based on usertype.

LVL 24

Accepted Solution

Joe Woodhouse earned 2000 total points
ID: 26301769
Is this Sybase ASE? If so, have a look at sp_help in sybsystemprocs, it has good SQL for getting the column structure.

Author Closing Comment

ID: 31676410
It worked great. I just forgot that i could check system procs. Thanks

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Check out the latest tech news, community articles, and expert highlights in August's newsletter.
In this modest contribution, I want to share with the IT community (especially system administrators, IT Support Engineers and IT Help Desks) about Windows crashes/hangs and how to deal with these particular problems.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question