如何得到时间段内的所有日期
给出起始时间和结束时间,然后的到之间的全部日期   
 例如其时日期为2007-1-1,结束日期为2007-1-5   
 得到如下结果   
 2007-1-1 
 2007-1-2 
 2007-1-3 
 2007-1-4 
 2007-1-5
------解决方案--------------------如果間隔大些的情況下,用循環的效率比較低,可以改用臨時表來實現。     
 Declare @StartDate DateTime, @EndDate DateTime 
 Select @StartDate =  '2007-1-1 ' , @EndDate =  '2007-1-5 ' 
 Select Top 100 Identity(Int, 0, 1) As ID Into #T from Sysobjects A, Sysobjects B  
 Select  
 	DateAdd(dd, ID, @StartDate) As [Date] 
 From #T 
 Where ID  <= DateDiff(dd, @StartDate, @EndDate) 
 Drop table #T 
 --Result 
 /* 
 Date 
 2007-01-01 00:00:00.000 
 2007-01-02 00:00:00.000 
 2007-01-03 00:00:00.000 
 2007-01-04 00:00:00.000 
 2007-01-05 00:00:00.000 
 */