查所有表的记录数,保留空间,使用空间,索引使用空间,未用空间

来源:互联网 发布:淘宝网密封胶圈 编辑:程序博客网 时间:2024/05/19 14:18
--查所有表的记录数,保留空间,使用空间,索引使用空间,未用空间
set nocount on exec sp_MSForEachTable @precommand=N'create table ##(id int identity,表名 sysname,字段数 int,记录数 int,保留空间 Nvarchar(10),使用空间 varchar(10),索引使用空间 varchar(10),未用空间 varchar(10))',@command1=N'insert ##(表名,记录数,保留空间,使用空间,索引使用空间,未用空间) exec sp_spaceused ''?''        update ## set 字段数=(select count(*) from syscolumns where id=object_id(''?'')) where id=scope_identity()',@postcommand=N'select * from ## order by 记录数 desc drop table ##'set nocount off


0 0
原创粉丝点击