Hi,First : sorry for my english but i'm french and i'm not get used to write in this language :)So, i want to know the size of ALL tables in ALL database with one stored procedure.I'm running under SQL Server 2000. This is what i do but the function 'USE' is not working...--SELECT name AS DBName, dbid as DBId, SUSER_SNAME(sid) AS Owner, crdate as CreationDate, cmptlevel AS CompatibilityLevel FROM master.dbo.sysdatabasesDeclare @temp varchar(50), @DBName_ varchar(100), @TBName_ varchar(100), @Size_ floatDeclare @sql varchar(8000), @proc varchar(8000)Set @sql = ''Set @proc = ''--Création de la table temporaireCREATE TABLE #sp_spaceused (TBName varchar(150), NbRows bigint, SReserved varchar(50), SData varchar(50), Sindex varchar(50), SFree varchar(50))Declare cursor_db CURSOR--On liste les basses des donnéesFor SELECT name AS DBName FROM master.dbo.sysdatabasesOPEN cursor_db Fetch next from cursor_db INTO @DBName_ WHILE @@Fetch_STATUS = 0 BEGIN --Print 'SELECT table_name FROM information_schema.tables WHERE table_Catalog= ''' + @DBName_ + ''' ' --Print 'USE ' + @DBName_ --On liste les tables... execute('USE ' + @DBName_ ) set @sql = 'Declare cursor_size CURSOR' set @sql = @sql + ' For SELECT table_name FROM ' + @DBName_ + '.information_schema.tables WHERE Table_Type = ''BASE TABLE''' --For SELECT table_name FROM information_schema.tables WHERE table_Catalog= @DBName_ and Table_Type = 'BASE TABLE' Execute(@sql) OPEN cursor_size Fetch next from cursor_size INTO @TBName_ WHILE @@Fetch_STATUS = 0 BEGIN if rtrim(@TBName_) <> '' BEGIN --insert into #sp_spaceused execute sp_spaceused @TBName_ execute('USE ' + @DBName_) --Go set @proc = 'insert into #sp_spaceused execute sp_spaceused ''' + @DBName_ + '.dbo.' + @TBName_ + '''' print @proc execute(@proc) END Fetch next from cursor_size INTO @TBName_ END CLOSE cursor_size; DEALLOCATE cursor_size; Fetch next from cursor_db INTO @DBName_ END CLOSE cursor_db;DEALLOCATE cursor_db;select * from #sp_spaceusedDrop Table #sp_spaceusedexecute sp_spaceused @TBName_
How can i do that?ThxPortekoi