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 '空欄位總數'