This will do it. It uses a number table generated by the function F_TABLE_NUMBER_RANGE to generate the next 300 dates, starting with today, and finds the first 10 that are not in the BOOKING table.declare @BOOKING table (DATE_BOOKED datetime not null )insert into @BOOKINGselect '2006-03-01' union allselect '2006-03-02' union allselect '2006-03-03' union allselect '2006-03-06' union allselect '2006-03-08' union allselect '2006-03-20' union allselect '2006-03-22'order by 1select top 10 UNBOOKED_DATE = dateadd(dd,datediff(dd,0,getdate())+a.NUMBER,0)from -- Function available in Script Library forum dbo.F_TABLE_NUMBER_RANGE(0,300) awhere dateadd(dd,datediff(dd,0,getdate())+a.NUMBER,0) not in ( select DATE_BOOKED from @BOOKING)order by NUMBER
Results:UNBOOKED_DATE ------------------------------------------------------ 2006-03-04 00:00:00.0002006-03-05 00:00:00.0002006-03-07 00:00:00.0002006-03-09 00:00:00.0002006-03-10 00:00:00.0002006-03-11 00:00:00.0002006-03-12 00:00:00.0002006-03-13 00:00:00.0002006-03-14 00:00:00.0002006-03-15 00:00:00.000(10 row(s) affected)
CODO ERGO SUM