Profile

Monday, 2 December 2013

Retrieve Column Names, Data Type from a table

A handy SQL query to retrieve column names, data type, and other info from a table.

SELECT
COLUMN_NAME,DATA_TYPE,
CHARACTER_MAXIMUM_LENGTH,
NUMERIC_PRECISION,
DATETIME_PRECISION,
IS_NULLABLE

FROM INFORMATION_SCHEMA.COLUMNS


WHERE TABLE_NAME='tablename'