SQL Server查询数据库中表使用空间信息实现脚本
程序员文章站
2022-10-10 15:29:09
使用了微软提供的不公开的存储过程sp_msforeachtable
create table #temp
(
tablename nva...
使用了微软提供的不公开的存储过程sp_msforeachtable
create table #temp ( tablename nvarchar (128), rowscnt varchar (11), reservedspace varchar(18), dataspace varchar(18), combinedindexspace varchar(18), unusedspace varchar(18) ) exec sp_msforeachtable'insert into #temp (tablename, rowscnt, reservedspace,dataspace, combinedindexspace, unusedspace) exec sp_spaceused ''?'', false' select tablename, rowscnt,reservedspace, dataspace, combinedindexspace, unusedspace from #temp order by tablename drop table #temp