Query to check whether a column is nullable

后端 未结 3 1309
自闭症患者
自闭症患者 2020-12-15 02:39

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.

3条回答
  •  渐次进展
    2020-12-15 03:04

    You could retrieve that from sys.columns:

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

提交回复
热议问题