Menu Close

TSQL – How To Get a Specified Column data type


SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME='table_name' and COLUMN_NAME in ('column_name','column_name2')

OR

SELECT
ORDINAL_POSITION
,COLUMN_NAME
,DATA_TYPE
,CHARACTER_MAXIMUM_LENGTH
,IS_NULLABLE
,COLUMN_DEFAULT
FROM
INFORMATION_SCHEMA.COLUMNS
WHERE
TABLE_NAME = 'youtablename'
ORDER BY
ORDINAL_POSITION ASC;