如何以编程方式确定视图列是否可为空?
http://sqlfiddle.com/#!18/b43f2
connect() {
const connection = getModule(Connection, this.$store);
connection.testAction();
this.$store.dispatch('Connection/rollbackRemoveItem');
}
create table tbl
(
a int not null,
b int null,
c int not null,
d int null
)
答案 0 :(得分:2)
您能从sys
对象中找到这个问题吗?
SELECT c.[name],
c.is_nullable
FROM sys.columns c
JOIN sys.views v ON c.object_id = v.object_id
WHERE v.name = N'vw';
答案 1 :(得分:2)
您可以使用SQL Server中的COLUMNPROPERTY方法进行检查
SELECT COLUMNPROPERTY(OBJECT_ID('SchemaName.ViewName', 'V'), 'ColumnName', 'AllowsNull');
将schemaName.ViewName替换为数据库架构和视图名称,例如dbo.vw并替换ColumnName,例如c:
SELECT COLUMNPROPERTY(OBJECT_ID('dbo.v', 'V'), 'c', 'AllowsNull');