1 --============== View the capacity size of a database table ========start================================?============2 Create Table#TableSpaceInfo--Create a result store table3 (4NameinfoNVarchar( -) , 5Rowsinfoint , 6ReservedNVarchar( -) , 7DatainfoNVarchar( -) , 8Index_sizeNVarchar( -) , 9UnusedNVarchar( -) Ten ) One A - Declare @TableName NVarchar(255)--Table name - Declare @CmdSql NVarchar( +) the - DeclareInfo_cursorCursor for - SelectO.name - fromdbo.sysobjects o + Where ObjectProperty(O.id, N'istable')= 1 andO.name not likeN'#%%' Order byO.name - + OpenInfo_cursor A at Fetch Next fromInfo_cursor - into @TableName - - while @ @FETCH_STATUS = 0 - Begin - If exists(Select * fromDbo.sysobjectsWhereId=object_id(@tablename) and ObjectProperty(ID, N'isusertable')= 1) in Executesp_executesql N'Insert into #TableSpaceInfo Exec sp_spaceused @TBName'N'@TBName NVarchar (255)',@TBName = @TableName - to Fetch Next fromInfo_cursor + into @TableName - End the * CloseInfo_cursor $ deallocateInfo_cursorPanax Notoginseng GO - the + --Itlearner Note: Display database information Asp_spaceused@UpdateUsage = 'TRUE' the + --Itlearner Note: Display table information - Select * $ from#TableSpaceInfo $ Order by cast( Left(LTrim(RTrim(Reserved)) ,Len(LTrim(RTrim(Reserved)))-2) as Int)Desc - - the Drop Table#TableSpaceInfo - --================ View the capacity size of a database table =====end========================?==========================