title: Is that possible to write the below query using CTE recursion?
body: <pre><code>create table #temp (date date)
  declare @X date
  set @X = '2016-7-01'
  declare @Y date 
  set @Y = cast (getdate() as date)
  while(@X&lt;=@Y) 
  begin
  if (datename(WEEKDAY,@X) = 'Sunday')
  insert into #temp values (@X)
  set @X = cast(((cast(@X as datetime))+1)as date)
  continue
  end
  select * from #temp
  drop table #temp
  </code></pre>
  
  <p>Is that possible to write the above query using CTE recursion?</p>