with ,Row_Number,DateDiff,DateAdd用法学习

  with tabs as  
 ( 
 select row_number() over (order by name) as rowNum , 
convert(varchar(10),dateadd(dd,number,convert(varchar(8),getdate(),120)+'01'),120) as dt 
from master..spt_values where type='P' 
and 
dateadd(dd,number,convert(varchar(8),getdate(),120)+'01')<=dateadd(dd,-1,convert(varchar(8),dateadd(mm,1,getdate()),120)+'01')
 )    
 select * from tabs where rowNum%2>0

 

posted @ 2013-07-13 22:52  Tom Fan  阅读(252)  评论(0编辑  收藏  举报