部分内容为学习过程中从网上搜集保存备份,以防源网站关闭后无法检索。如有涉及版权请留言,看到后处理

sqlserver查询数据的所有表名和行数

//查询所有表明
select name from sysobjects where xtype='u'

select * from sys.tables


//查询数据库中所有的表名及行数

SELECT a.name, b.rows

FROM sysobjects AS a INNER JOIN sysindexes AS b ON a.id = b.id

WHERE (a.type = 'u') AND (b.indid IN (0, 1))

ORDER BY a.name,b.rows DESC


//查询所有的标明及空间占用量\行数

select

object_name(id) tablename,

8*reserved/1024 reserved,

rtrim(8*dpages)+'kb' used,

8*(reserved-dpages)/1024 unused,

8*dpages/1024-rows/1024*minlen/1024 free,

rows

--,*

from sysindexes

where indid=1

order by tablename,reserved desc

 

posted @ 2016-06-23 16:17  Y档案Y  阅读(214)  评论(0编辑  收藏  举报