December 8, 2008 at 2:11 pm
Hi there,
I am trying to retreive Column information from the DB. I am interested in getting Column name,its datatype and length of the column.
Using system views, I am getting column name and its datatype but is working with obtaining length of the column.
Does anyone know thru which system view, I can get that.
Thanks
December 8, 2008 at 2:23 pm
It depends on what datatype the column is and which "system views" you are using.
The easiest one to use is information_schema.columns
it has character_maximum_length column for CHAR, NCHAR, VARCHAR, NVARCHAR columns, and numeric_precision, numeric_scale for DECIMAL, NUMBER columns.
Simmilarly, in sys.columns, there is max_length for CHAR and VARCHAR, but you need to divide by 2 for NCHAR and NVARCHAR since they take 2 bytes per character. For DECIMAL and NUMBER use the precision and scale columns.
December 8, 2008 at 2:37 pm
Thanks!
I figured out..
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy