查询以检查列是否可为空
问题描述:
查询一列是否可以为空(列中是否允许空值).它最好应该返回 yes/no 或 1/0 或 true/false.
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.
答
您也可以使用 COLUMNPROPERTY
和 OBJECT_ID
元数据函数:
You could also use the COLUMNPROPERTY
and OBJECT_ID
metadata functions:
SELECT COLUMNPROPERTY(OBJECT_ID('SchemaName.TableName', 'U'), 'ColumnName', 'AllowsNull');