SQL statement to get column type

daniely picture daniely · Nov 15, 2012 · Viewed 635.1k times · Source

Is there a SQL statement that can return the type of a column in a table?

Answer

Francis P picture Francis P · Nov 15, 2012

Using SQL Server:

SELECT DATA_TYPE 
FROM INFORMATION_SCHEMA.COLUMNS
WHERE 
     TABLE_NAME = 'yourTableName' AND 
     COLUMN_NAME = 'yourColumnName'