SQL Server: Checking the datatype of a column
sql-server-2008, sqldatatypes
Solution
select COLUMN_NAME
from INFORMATION_SCHEMA.COLUMNS
where DATA_TYPE = 'char'
and CHARACTER_MAXIMUM_LENGTH = 11
and TABLE_NAME = 'your_table'
using `syscolumns`:
SELECT name FROM SYSCOLUMNS
where length = 11
and xtype = 175 --char type
Problem
How to check if a column in a table has a specific datatype? For example, how to check if a column in SQL Server table is of datatype `char(11)`?