查询某个schema下所有表:
select * from schema..sysobjects where xtype='U'
若表明为数字等特殊表名,可以加[ ]:
select * from shema..[1001]
查询某个shema下所有表的行数:
SELECT a.name, b.rows FROM schema..sysobjects AS a INNER JOIN schema..sysindexes AS b ON a.id = b.id WHERE (a.xtype = 'U') AND (b.indid IN (0, 1)) ORDER BY a.name,b.rows DESC
查询某个shema下所有表名和空间使用情况以及行数:
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