I am trying to get maximum allowed column length (characters count in representation, not bytes count) from MS SQL from INFORMATION_SCHEMA.COLUMNS table. I have found that CHARACTER_MAXIMUM_LENGTH can be NULL for numeric and datetime types. I also have found three following columns in INFORMATION_SCHEMA.COLUMNS table:
- NUMERIC_PRECISION;
- NUMERIC_SCALE (related to NUMERIC_PRECISION);
- DATETIME_PRECISION;
As i understand there is always at least on non NULL value of column exists, so we can use that columns to get maximum length. I can`t found clear specification about this columns usage. For example lets say i have DATETIME_PRECISION equals 3 for datetime type, how i can calculate characters count from that '3' using only INFORMATION_SCHEMA tables?