在线咨询
QQ咨询
服务热线
服务热线:13125520620
TOP

获得所有表的表记录,和使用空间的SQL-数据库

发布时间:2011-11-12 浏览:4797

获得所有表的表记录,和使用空间的SQL

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 id drop table ##'

TAG
软件定制,软件开发,瀚森HANSEN
0
该内容对我有帮助