刚才突然有这么个奇怪的需求,找到了这个SQL写法:

SELECT t.name, COUNT(c.name) AS Expr1
FROM   sys.tables AS t INNER JOIN
             sys.columns AS c ON t.object_id = c.object_id
GROUP BY t.name
ORDER BY expr1

虽然很短,可以记录一下,以后万一用到,可以翻出来用。