Query to check whether a column is nullable

后端 未结 3 1269
自闭症患者
自闭症患者 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 02:49

    You could also use the COLUMNPROPERTY and OBJECT_ID metadata functions:

    SELECT COLUMNPROPERTY(OBJECT_ID('SchemaName.TableName', 'U'), 'ColumnName', 'AllowsNull');
    

提交回复
热议问题