declareCursor1Cursor
for
selectnamefromsysobjectswherextype=U
openCursor1
fetchnextfromCursor1into@TableName
while@@fetch_status=0
begin
set@sql=insertintoTableSpace
set@sql=@sql+execsp_spaceused+@TableName+
exec(@sql)
fetchnextfromCursor1into@TableName
end
closeCursor1
deallocateCursor1
go
--显现了局
select*fromTableSpace
--orderbyTableName
--orderbyTableNameASC--按表称号,用于统计表
--orderbyRowsCountDESC--按行数目,用于检察表行数
--orderbyReservedDESC,DataDESC--按占用空间
--orderbyIndex_sizeDESC,ReservedDESC--按索引空间检察
go