 
 SELECT ServerName = @@SERVERNAME
     , DatabaseName = r.DatabaseName
-    , LastKnownGoodDate = CONVERT(DATETIME, r.value, 120)
-    , AtRisk = CASE WHEN DATEDIFF(day, CONVERT(DATETIME, r.value, 120), GETDATE()) > @MaxDaysWithoutCheckDB THEN 'X' ELSE '' END
+    , LastKnownGoodDate = CONVERT(DATETIME, r.Value, 120)
+    , AtRisk = CASE WHEN DATEDIFF(day, CONVERT(DATETIME, r.Value, 120), GETDATE()) > @MaxDaysWithoutCheckDB THEN 'X' ELSE '' END
     , IsDBOnline = r.IsOnline
 FROM #Results r
-WHERE r.field = 'dbi_dbccLastKnownGood'
-    OR r.field IS NULL;
+WHERE r.Field = 'dbi_dbccLastKnownGood'
+    OR r.Field IS NULL;

    RAISERROR (@dbName, 0, 1) WITH NOWAIT;
    IF @IsOnline = 1
    BEGIN
        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;
