Thanks for sharing. one comment, it is a little less overhead to increment negatively to zweo instead of having another variable @i and incrementing it by +1:
Declare @DBCnt int, @iCur int;
DECLARE @dbs as Table (DBName varchar(100), DBNumber int) --Temp table for DBs to run against
INSERT INTO @dbs select [name] as DBName, ROW_NUMBER() OVER(PARTITION BY 1 ORDER BY [name]) AS DBNumber from sys.databases;
set @DBCnt = @@rowcount
WHILE @DBCnt > 0 --Start loop over all DB's
BEGIN
select * FROM @dbs where DBNumber = @DBCnt;
-- do something
set @DBCnt = @DBCnt-1;
END