非空字段数
程序员文章站
2022-06-27 19:40:54
select count(*) '总字段数', ISNULL(ISNULL(sum(case when isnullable=0 then 1 end),null),null) as '非空字段数' from syscolumns where id=object_id( 'EmpInfo') --空 ......
select count(*) '总字段数',
ISNULL(ISNULL(sum(case when
isnullable=0 then 1 end),null),null) as '非空字段数'
from syscolumns where id=object_id( 'EmpInfo')
--空字段总数
SELECT
(
(SELECT COUNT(*) FROM syscolumns WHERE id=object_id('表名'))-
(SELECT sum(CASE WHEN isnullable=0 then 1 end) FROM syscolumns
WHERE id=object_id('EmpInfo'))
)as '空字段总数'