萬盛學電腦網

 萬盛學電腦網 >> 數據庫 >> sql server教程 >> aboutspaceused

aboutspaceused

--sql server 6.5/7.0 中有查看某個庫中表的占用空間信息功能,但SQL Server 2000中就沒有此功能了,偶隨手編了一段語句,權當補缺,但沒有排序功能,有興趣的同志可加上排序功能   SET NOCOUNT ON
declare @TableName varchar(200)
create table #tmpTable(name nvarchar(20),rows char(11),reserved varchar(18),data varchar(18),index_size varchar(18),unused varchar(18))
DECLARE myCursor CURSOR FOR  select name from sysobjects where type='u'
OPEN myCursor
FETCH NEXT FROM myCursor into @TableName
WHILE @@FETCH_STATUS = 0
BEGIN
   insert into #tmptable exec sp_spaceused @TableName
   FETCH NEXT FROM myCursor into @TableName
END
CLOSE myCursor
DEALLOCATE myCursor
select * from #tmpTable
drop table #tmpTable
GO

關鍵詞:

copyright © 萬盛學電腦網 all rights reserved