SET LANGUAGE (Transact-SQL)SET LANGUAGE (Transact-SQL)
适用于:Applies to: SQL ServerSQL Server(所有支持的版本)
SQL ServerSQL Server (all supported versions)
Azure SQL 数据库Azure SQL Database
Azure SQL 数据库Azure SQL Database
Azure SQL 托管实例Azure SQL Managed Instance
Azure SQL 托管实例Azure SQL Managed Instance
Azure Synapse AnalyticsAzure Synapse Analytics
Azure Synapse AnalyticsAzure Synapse Analytics
SQL ServerSQL Server(所有支持的版本)
SQL ServerSQL Server (all supported versions)
Azure SQL 数据库Azure SQL Database
Azure SQL 数据库Azure SQL Database
Azure SQL 托管实例Azure SQL Managed Instance
Azure SQL 托管实例Azure SQL Managed Instance
Azure Synapse AnalyticsAzure Synapse Analytics
Azure Synapse AnalyticsAzure Synapse Analytics
指定会话的语言环境。Specifies the language environment for the session. 会话语言确定 datetime 格式和系统消息。The session language determines the datetime formats and system messages.
Transact-SQL 语法约定
Transact-SQL Syntax Conventions
语法Syntax
SET LANGUAGE { [ N ] 'language' | @language_var }
备注
若要查看 SQL Server 2014 及更早版本的 Transact-SQL 语法,请参阅早期版本文档。To view Transact-SQL syntax for SQL Server 2014 and earlier, see Previous versions documentation.
参数Arguments
[N] ' language ' | @ language_var[N]'language' | @language_var
存储在 sys.syslanguages 中的语言的名称。Is the name of the language as stored in sys.syslanguages. 此参数可以是 Unicode,或者是转换为 Unicode 的 DBCS。This argument can be either Unicode or DBCS converted to Unicode. 若要指定使用 Unicode 的语言,请使用 N' language ' 。To specify a language in Unicode, use N'language'. 如果将语言指定为变量,则变量的数据类型必须为 sysname。If specified as a variable, the variable must be sysname.
注解Remarks
SET LANGUAGE 的设置是在执行或运行时设置,而不是在分析时设置。The setting of SET LANGUAGE is set at execute or run time and not at parse time.
SET LANGUAGE 隐式设置 SET DATEFORMAT 的设置。SET LANGUAGE implicitly sets the setting of SET DATEFORMAT.
权限Permissions
要求 公共 角色具有成员身份。Requires membership in the public role.
示例Examples
以下示例将默认语言设置为 Italian
,显示月份,然后切换回 us_english
并再次显示月份名。The following example sets the default language to Italian
, displays the month name, and then switches back to us_english
and displays the month name again.
DECLARE @Today DATETIME;
SET @Today = '12/5/2007';
SET LANGUAGE Italian;
SELECT DATENAME(month, @Today) AS 'Month Name';
SET LANGUAGE us_english;
SELECT DATENAME(month, @Today) AS 'Month Name' ;
GO
另请参阅See Also
数据类型 (Transact-SQL) Data Types (Transact-SQL)
syslanguages syslanguages
sp_helplanguage (Transact-SQL) sp_helplanguage (Transact-SQL)
SET 语句 (Transact-SQL)SET Statements (Transact-SQL)