Home Forums SQL Server 2005 T-SQL (SS2K5) Obtaining information about table using System views RE: Obtaining information about table using System views

  • 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.