     END
     ELSE
     BEGIN
-        INSERT INTO #Results (DatabaseName, IsOnline)
-        VALUES (@dbName, @IsOnline)
+        INSERT INTO #Results
+            (DatabaseName, IsOnline)
+        VALUES
+            (@dbName, @IsOnline)
     END
 
     FETCH NEXT FROM cur INTO @cmd, @dbName, @IsOnline;


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
    , IsDBOnline = r.IsOnline
FROM #Results r
WHERE r.field = 'dbi_dbccLastKnownGood'
    OR r.field IS NULL;

/*
Author: Max Vernon
Original link: https://www.sqlserverscience.com/maintenance/check-dbcc-checkdb/
Modified: 2018-01-26 18:20 by Konstantin Taranov
*/


