I have a Table_A with the column Name and Data Type as below:
QUANTITY int PO_NO varchar(13) FLG char(1) AMOUNT money I want to make the query that return the result like this:
QUANTITY TYPE="3" LENGHT="4" PO_NO TYPE="200" LENGHT="13" FLG TYPE="129" LENGHT="1" AMOUNT TYPE="6" LENGTH="8" I use this query to get column schema, but the result is not same as my expectation
select COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='Table_A' Results:
COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH QUANTITY int NULL PO_NO varchar 13 FLG char 1 AMOUNT money NULL So , my question is: How to know the data type int is equivalent to Type=3 and length =4 and so on.
INFORMATION_SCHEMAviews return the logical schema, not the physical implementation. You can get the desired result using catalog views likesys.columnstogether with mapping SQL types to ADO types codes. Why do you care about the physical length in bytes of the data types?