请问如何生成某月份的日历?
要求把日历放在select 中最后取出来
------解决方案--------------------http://community.csdn.net/Expert/topic/5619/5619131.xml?temp=.0504114
Declare @Year int, @Month Int
Select @Year = 2007, @Month = 7
Select TOP 50 ID = Identity(Int, 0, 1) Into #T From SysColumns
Select Convert(Varchar(10), DateAdd(dd, ID, Cast(Rtrim(@Year) + '- ' + Rtrim(@Month) + '- ' + '01 ' As DateTime)), 120) From #T
Where ID < DateDiff(dd, Cast(Rtrim(@Year) + '- ' + Rtrim(@Month) + '- ' + '01 ' As DateTime), DateAdd(mm, 1, Cast(Rtrim(@Year) + '- ' + Rtrim(@Month) + '- ' + '01 ' As DateTime)))
Drop Table #T
--Result
/*
2007-07-01
2007-07-02
2007-07-03
2007-07-04
2007-07-05
2007-07-06
2007-07-07
2007-07-08
2007-07-09
2007-07-10
2007-07-11
2007-07-12
2007-07-13
2007-07-14
2007-07-15
2007-07-16
2007-07-17
2007-07-18
2007-07-19
2007-07-20
2007-07-21
2007-07-22
2007-07-23
2007-07-24
2007-07-25
2007-07-26
2007-07-27
2007-07-28
2007-07-29
2007-07-30
2007-07-31
*/