title: Connect by level for SQL Server 2008 like Oracle
body: <pre><code>nDays := Round( dEndTime - dStartTime ) + 1; 
  
  For i in 1..7 Loop
   nDay := i + 1;
      if i = 7 Then
        nDay := 1;
      End If;
  
  SELECT To_Date(To_Char((dStartTime+Level-1),'DD.MM.YYYY')||' 00:00','DD.MM.YYYY HH24:MI'),
  To_Date(To_Char((dStartTime+Level-1),'DD.MM.YYYY')||' 23:59','DD.MM.YYYY HH24:MI')
  FROM DUAL
  WHERE To_Char( dStartTime + Level -1 , 'd' ) =  To_Char(nDay)
  CONNECT BY Level &lt;= nDays;
  
  End Loop;
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>22-JUL-12
  23-JUL-12
  18-JUL-12
  19-JUL-12
  20-JUL-12
  21-JUL-12
  </code></pre>
  
  <p>I need to convert this query to SQL Server 2008, please help to find workaround with the same......</p>
  
  <p>I have tried above output with single query with nDay from 1 to 7.....</p>