about "space used"

类别:数据库 点击:0 评论:0 推荐:
--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

本文地址:http://com.8s8s.com/it/it21347.htm