网上盛传着三个版本,分别来看下
版本1
http://bernardstudios.com/select-day-of-week-name-using-t-sql/
SELECT
CASE (DATEPART(dw, GETDATE()) + @@DATEFIRST) % 7
WHEN 1 THEN 'Sunday'
WHEN 2 THEN 'Monday'
WHEN 3 THEN 'Tuesday'
WHEN 4 THEN 'Wednesday'
WHEN 5 THEN 'Thursday'
WHEN 6 THEN 'Friday'
WHEN 0 THEN 'Saturday'
END AS DayOfWeekName
DayOfWeekName
-------------
Wednesday
(1 行受影响)
版本2
来自园子里某位朋友的
http://www.cnblogs.com/geovindu/archive/2011/08/15/2139751.html
版本3
SET LANGUAGE N'简体中文'
SELECT DATENAME(weekday, GETDATE()) as DayOfWeekName
--SELECT name FROM sys.syslanguages
已将语言设置更改为 简体中文。
DayOfWeekName
------------------------------
星期三
(1 行受影响)
显然第三种方案在MSSQL中是最简洁的写法,那个LANGUAGE参数可以参考系统表得到:
SELECT name FROM sys.syslanguages
name
--------------------------------------------------------------------------------------------------------------------------------
us_english
Deutsch
Français
日本語
Dansk
Español
Italiano
Nederlands
Norsk
Português
Suomi
Svenska
čeština
magyar
polski
română
hrvatski
slovenčina
slovenski
ελληνικά
български
русский
Türkçe
British
eesti
latviešu
lietuvių
Português (Brasil)
繁體中文
한국어
简体中文
Arabic
ไทย
(33 行受影响)
全剧终