修正 declare @i int--統計表的數目 declare @aa varchar(20) --set @i=1 while @aa<>'' SET @aa=(substring('ABCDEFG',@i,1))--把表名放在一起 EXEC sp_spaceused @aa set @i=@i+1
use hahadeclare @tbname varchar(1000) declare cu cursor for select name from sysobjects where xtype ='U' open cu fetch cu into @tbname while(@@fetch_status=0) begin EXEC sp_spaceused @tbname fetch cu into @tbname end
忘了释放游标了 declare @tbname varchar(1000) declare cu cursor for select name from sysobjects where xtype ='U' open cu fetch cu into @tbname while(@@fetch_status=0) begin EXEC sp_spaceused @tbname fetch cu into @tbname end close cu deallocate cu
declare @aa varchar
set@i=1
while @aa<>''
set@aa=substring(abcdefg,@i)--把表名放在一起
sp_spaceused '@aa'
set@i=@i+1
loop
declare @i int--統計表的數目
declare @aa varchar(20)
--set @i=1
while @aa<>''
SET @aa=(substring('ABCDEFG',@i,1))--把表名放在一起
EXEC sp_spaceused @aa
set @i=@i+1
declare cu cursor for
select name from sysobjects where xtype ='U'
open cu
fetch cu into @tbname
while(@@fetch_status=0)
begin
EXEC sp_spaceused @tbname
fetch cu into @tbname
end
declare @tbname varchar(1000)
declare cu cursor for
select name from sysobjects where xtype ='U'
open cu
fetch cu into @tbname
while(@@fetch_status=0)
begin
EXEC sp_spaceused @tbname
fetch cu into @tbname
end
close cu
deallocate cu