I would use a Recursive Common Table Expression (CTE) like so:
declare @start date, @end date
set @start = '01 aug 2015'
set @end = '20 aug 2015'
;
with dates as (
select @start [date]
union all
select dateadd(day,1,[date])
from dates
where [date] < @end
)
select * from dates
where datepart(weekday,[date]) > 1
You can join this to your other table without any conditions like so:
declare @start date, @end date
set @start = '01 aug 2015'
set @end = '20 aug 2015'
;
with dates as (
select @start [date]
union all
select dateadd(day,1,[date])
from dates
where [date] < @end
)
select codes.code,dates.date from dates , codes
where datepart(weekday,[date]) > 1
this will show all of your codes, each with all of the dates
Hope that helps ^_^
Andy