請問這個語句應該怎麼去寫?
答 if object_id(tablename) is not null drop table tablename
select as time_id as time_date as [year] as week_of_year 星期日 as [day]
into tablename
union select 星期一
union select 星期二
select time_id time_date [year] 第 + cast(week_of_year as varchar()) + 周(
+ cast(month(week_begin) as varchar()) + / + cast(day(week_begin) as varchar()) +
+ cast(month(week_end) as varchar()) + / + cast(day(week_end) as varchar()) as week_of_year
from (select * dateadd(day datepart(weekday time_date) time_date) as week_begin
dateadd(day datepart(weekday time_date) time_date) as week_end from tablename) a
/*
time_id time_date year week_of_year
第周(//)
第周(//)
第周(//)
*/
drop table tablename
[] [] [] [] []
From:http://tw.wingwit.com/Article/program/SQL/201311/16172.html