以下示例演示了在不同的语言环境(SET LANGUAGE)下,DATENAME与CONVERT函数的不同结果。
复制代码 代码如下:
USE master
--设置会话的语言环境为: English
SET LANGUAGE N'English'
SELECT
DATENAME(Month,GETDATE()) AS [Month],
DATENAME(Weekday,GETDATE()) AS [Weekday],
CONVERT(varchar,GETDATE(),109) AS [CONVERT]
/**//*--结果:
Month Weekday CONVERT
------------- -------------- -------------------------------
March Tuesday Mar 15 2005 8:59PM
--*/
--设置会话的语言环境为: 简体中文
SET LANGUAGE N'简体中文'
SELECT
DATENAME(Month,GETDATE()) AS [Month],
DATENAME(Weekday,GETDATE()) AS [Weekday],
CONVERT(varchar,GETDATE(),109) AS [CONVERT]
/**//*--结果
Month Weekday CONVERT
------------- --------------- -------------------------------
05 星期四 05 19 2005 2:49:20:607PM
--*/