当前位置: 代码迷 >> SQL >> SQL Server 2000 台历
  详细解决方案

SQL Server 2000 台历

热度:331   发布时间:2016-05-05 13:27:20.0
SQL Server 2000 日历
/*-----------------------------------------------*//*		输入年份即可求日历		 *//*-----------------------------------------------*/declare @year as varchar(10) set @year='2009'/*-----------------------------------------------*//*		    基本参数			 *//*-----------------------------------------------*/declare @date as smalldatetime		--该年的开始日期declare @enter as varchar(20)		--换行declare @tab as varchar(20)		--退格declare @weekDayStr as varchar(3000)	--星期几declare @outPrint as varchar(5000)	--所有字符串的集合set @date=cast(@year+'-1-1' as smalldatetime)set @enter=char(13)set @tab=char(9)set @[email protected][email protected][email protected][email protected][email protected][email protected]+'星期六'set @outPrint=''	--null/*-----------------------------------------------*//*		    形成每月的日历		 *//*-----------------------------------------------*/while(datename(mm,@date)<=12 and datename(mm,@date)>=1 and datename(yy,@date)[email protected])begin	--显示标题	set @[email protected][email protected]+		[email protected]+		'		    '+datename(yy,@date)+'年'+datename(mm,@date)[email protected]+		[email protected]	set @[email protected][email protected][email protected]		--显示每月前的空格	set @[email protected]+(case datename(dw,@date)		when '星期一' then @tab		when '星期二' then @[email protected]		when '星期三' then @[email protected][email protected]		when '星期四' then @[email protected][email protected][email protected]		when '星期五' then @[email protected][email protected][email protected][email protected]		when '星期六' then @[email protected][email protected][email protected][email protected][email protected]		else ''	end)		--上个月的月份	declare @tempMonth as int	set @tempMonth=datename(mm,@date)	--显示该月日历	while(datename(mm,@date)[email protected])	begin		if datename(dw,@date)='星期六'			set @[email protected]+datename(dd,@date)[email protected]		else			set @[email protected]+datename(dd,@date)[email protected]		--日期加1		set @date=dateAdd(dd,1,@date)	end		set @[email protected][email protected]end/*-----------------------------------------------*//*		    显示结果			 *//*-----------------------------------------------*/print @outPrint

?闲来无事,找到以前做过的一个日历,放到上面,希望对大家有所帮助,同时也加深自己的记忆。

?

  相关解决方案