找了半天的资料,将mysql的实现了SELECT sum(DATA_LENGTH) as RESERVED FROM information_schema.`TABLES` where TABLE_SCHEMA='database1' and TABLE_NAME = 'datatable1'
但是sqlserver的一直不知道怎么实现,使用exec sp_spaceused datatable1,true
只能查询一张表,如果使用exec sp_spaceused,得到的结果是分开的。
我想实现的类似下面得到的某几张表的大小
但是sqlserver的一直不知道怎么实现,使用exec sp_spaceused datatable1,true
只能查询一张表,如果使用exec sp_spaceused,得到的结果是分开的。
我想实现的类似下面得到的某几张表的大小
select * from dbo.sysdatabases 2. 以SQL2000自带PUBS为例exec sp_MSForEachTable
@precommand=N'create table ##(
表名 sysname,
记录数 int,
保留空间 Nvarchar(10),
使用空间 varchar(10),
索引使用空间 varchar(10),
未用空间 varchar(10))',
@command1=N'insert ## exec sp_spaceused ''?''',
@postcommand=N'select * from ## order by 记录数 '
--统计数据库里每个表的详细情况
exec sp_MSforeachtable @command1="sp_spaceused '?'"