Monday, September 15, 2014

how to check data type size in sql server 2008


select COLUMN_NAME 
from INFORMATION_SCHEMA.COLUMNS
where DATA_TYPE = 'Data type of column like varchar ,char etc. '
and CHARACTER_MAXIMUM_LENGTH = size of col like 100 ,200 etc
and TABLE_NAME = 'your_table'
 
 
 
 
Ex:
select COLUMN_NAME 
from EmpDB.INFORMATION_SCHEMA.COLUMNS 
where DATA_TYPE = 'varchar'
and CHARACTER_MAXIMUM_LENGTH = 2000
and TABLE_NAME = 'EmpDemo'