SQL Servers2008中,如何將表中數據星期從英文轉化爲中文,並用一條語句來完成.
題目:
SQL Servers2008中,如何將表中數據星期從英文轉化爲中文,並用一條語句來完成.
TimeKey FullDateAlternateKey\x05DayNumberOfWeek\x05EnglishDayNameOfWeek
1\x052001-07-01 0:00:00\x051\x05\x05Sunday
2\x052001-07-02 0:00:00\x052\x05\x05Monday
3\x052001-07-03 0:00:00\x053\x05\x05Tuesday
4\x052001-07-04 0:00:00\x054\x05\x05Wednesday
5\x052001-07-05 0:00:00\x055\x05\x05Thursday
6\x052001-07-06 0:00:00\x056\x05\x05Friday
7\x052001-07-07 0:00:00\x057\x05\x05Saturday
8\x052001-07-08 0:00:00\x051\x05\x05Sunday
9\x052001-07-09 0:00:00\x052\x05\x05Monday
TimeKey FullDateAlternateKey DayNumberOfWeek\x05EnglishDayNameOfWeek
1\x052001-07-01 0:00:00\x05 1\x05\x05Sunday
2\x052001-07-02 0:00:00\x05 2\x05\x05Monday
3\x052001-07-03 0:00:00\x05 3\x05\x05Tuesday
4\x052001-07-04 0:00:00\x05 4\x05\x05Wednesday
5\x052001-07-05 0:00:00 \x055\x05\x05Thursday
6\x052001-07-06 0:00:00 \x056\x05\x05Friday
7\x052001-07-07 0:00:00 \x05 7\x05\x05Saturday
8\x052001-07-08 0:00:00 \x051\x05\x05Sunday
9\x052001-07-09 0:00:00 \x052\x05\x05Monday
解答:
1.select datename(weekday,DayNumberOfWeekEnglishDayNameOfWeek
)
2.select datename(weekday,FullDateAlternateKey)
再問: 高手,你在琢磨一下
再答: select case when EnglishDayNameOfWeek = 'Sunday' then '星期日' when EnglishDayNameOfWeek = 'Monday' then '星期一' when EnglishDayNameOfWeek = 'Tuesday' then '星期二' when EnglishDayNameOfWeek = 'Wednesday' then '星期三' when EnglishDayNameOfWeek = 'Thursday' then '星期四' when EnglishDayNameOfWeek = 'Firday' then '星期五' when EnglishDayNameOfWeek = 'Saturday' then '星期六' else '' end from tableName 可以嘗試下以上SQL 語句
添加新評論