--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