获取表行数
2012-07-24 13:42 Patrick.Lee 阅读(199) 评论(0) 编辑 收藏 举报CREATE TABLE #tmp(
tablename SYSNAME,
[rows] INT,
reserved NVARCHAR(200),
data NVARCHAR(200),
index_size NVARCHAR(200),
unused NVARCHAR(200))
EXEC sp_MSForEachTable 'INSERT #tmp EXEC sp_spaceused ''?'''
SELECT #tmp.*
FROM #tmp
INNER JOIN sys.all_objects as ao
ON #tmp.tablename = ao.name
WHERE ao.schema_id = 1
ORDER by [rows] DESC