     RAISERROR (@dbName, 0, 1) WITH NOWAIT;
     IF @IsOnline = 1
     BEGIN
-        INSERT INTO #Results (ParentObject, [Object], [Field], [Value])
+        INSERT INTO #Results
+            (ParentObject, [Object], [Field], [Value])
         EXEC sp_executesql @cmd;
+
         UPDATE #Results 
         SET DatabaseName = @dbName
             , IsOnline = @IsOnline

    END
    ELSE
    BEGIN
        INSERT INTO #Results (DatabaseName, IsOnline)
        VALUES (@dbName, @IsOnline)
    END

    FETCH NEXT FROM cur INTO @cmd, @dbName, @IsOnline;

    , [Value] varchar(100) NULL
);

DECLARE @cmd NVARCHAR(4000);
DECLARE @dbName SYSNAME;
DECLARE @IsOnline BIT;

DECLARE cur CURSOR LOCAL FORWARD_ONLY STATIC READ_ONLY
FOR
SELECT DBCCCommand = CAST(N'DBCC DBINFO(N''' + d.name + N''') WITH TABLERESULTS;' AS NVARCHAR(500))
    , DatabaseName = d.name
    , IsOnline = CONVERT(BIT, CASE WHEN d.state_desc = 'ONLINE' THEN 1 ELSE 0 END)
FROM sys.databases d
