if object_id('tempdb..#Data') is not null DROP TABLE #Data
if object_id('tempdb..#dataNew') is not null DROP TABLE #dataNew
create table #Data(name varchar(100),row varchar(100),reserved varchar(100),data varchar(100),index_size varchar(100),unused varchar(100))
declare @name varchar(100)
declare cur cursor for
select name from sysobjects where xtype='u' order by name
open cur
fetch next from cur into @name
while @@fetch_status=0
begin
insert into #data
exec sp_spaceused @name
print @name
fetch next from cur into @name
end
close cur
deallocate cur
create table #DataNew(name varchar(100),row int,reserved int,data int,index_size int,unused int)
insert into #dataNew
select name,convert(int,row) as row,convert(int,replace(reserved,'KB','')) as reserved,convert(int,replace(data,'KB','')) as data,
convert(int,replace(index_size,'KB','')) as index_size,convert(int,replace(unused,'KB','')) as unused from #data
select * from #dataNew order by data DESC
相关文章
- SQLSERVER 和 ORACLE 查询数据库文件大小
- 【转载】C#常用数据库Sqlserver通过SQL语句查询数据库以及表的大小
- sqlserver 2000数据库中如何查询某个字段插入值后的系统时间
- 2019-2-20Sqlserver数据库中char、varchar、nchar、nvarchar的区别及查询表结构
- sqlserver isnull在数据库查询中的应用
- mysql查询数据库中每一张表的内存大小
- 查询数据库中表数量和各表中数据量
- SQLSERVER查询整个数据库中某个特定值所在的表和字段的方法
- SQLSERVER查询整个数据库中某个特定值所在的表和字段的方法
- SQLSERVER查询整个数据库中某个特定值所在的表和字段的方法