Query to check whether a column is nullable

user646093 picture user646093 · Mar 5, 2011 · Viewed 41.7k times · Source

Query to check whether a column is nullable (null values are allowed in the column or not). It should preferably return yes/no or 1/0 or true/false.

Answer

Andomar picture Andomar · Mar 5, 2011

You could retrieve that from sys.columns:

select  is_nullable 
from    sys.columns 
where   object_id = object_id('Schema.TheTable') 
        and name = 'TheColumn'