现在需要实现这样的sql函数 传入年月生成一列日期以及对应的一列星期几 表我自己已定义 year_month_week 包括列current_date 以及列current_week
请问应该怎样实现这样的函数

解决方案 »

  1.   

    类似这样的函数
    CREATE function calander(@month int,@year int)
    begin
    ......
    end函数传入月份参数年份参数实现把月份以及星期几添加至表year_month_week
    类似如下效果
    current_date    current_week
    2012-2-1             星期几
    ...                   ... 
      

  2.   

     dateadd() / master..spt_values 
      

  3.   

    set datefirst 1
    select DATEPART(WEEKDAY,getdate())