SQL查询每个表的字段数量

--SQL查询每个表的字段数量
select b.[name], count(*) As AllCount,
ISNULL(ISNULL(sum(case when
isnullable=0 then 1 end),null),null) as NotNullCount
from syscolumns a
INNER JOIN
(
select [id], [name] from [sysobjects] where [type] = 'u'

) AS b ON a.id = b.[id]
GROUP by b.[name]
ORDER by AllCount asc

posted @ 2017-01-04 11:10  奔跑的风.h  阅读(5192)  评论(0编辑  收藏  举报