                                 FOR
                                   XML PATH('')
                                 ), 1, 2, '');
- 
+
+IF @RunStartedList IS NULL THROW 50000, @THROW50000, 1;
+
 SELECT  @SQL = '
 WITH    JobRuns
           AS ( SELECT   jh.instance_id ,

/*
Author: Buck Woody
Original link: https://thelonedba.wordpress.com/2016/07/18/which-databases-were-backed-up-in-which-backup-task/
*/


DECLARE @SQL VARCHAR(MAX);
DECLARE @RunStartedList VARCHAR(MAX);
DECLARE @NumDays INT;
SELECT  @NumDays = 10; -- not doing this as a single line declare-define, as we might be running on older versions.
 
IF @NumDays > 0
    BEGIN

ORDER BY sd.name ,
        bp.DBName
       ;
';

IF @debug = 1 PRINT(@SQL);
ELSE
EXEC(@SQL);

