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
文章来源于领测软件测试网 https://www.ltesting.net/










