SET LANGUAGE (Transact-SQL)SET LANGUAGE (Transact-SQL)

適用於: 是SQL Server 是Azure SQL Database 是Azure SQL 資料倉儲 否平行處理資料倉儲 APPLIES TO: yesSQL Server yesAzure SQL Database yesAzure SQL Data Warehouse noParallel Data Warehouse

指定工作階段的語言環境。Specifies the language environment for the session. 工作階段語言決定 datetime 格式和系統訊息。The session language determines the datetime formats and system messages.

主題連結圖示 Transact-SQL 語法慣例Topic link icon Transact-SQL Syntax Conventions

語法Syntax

  
SET LANGUAGE { [ N ] 'language' | @language_var }   

引數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'. 如果指定為變數,變數必須是 sysnameIf specified as a variable, the variable must be sysname.

RemarksRemarks

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

需要 public 角色的成員資格。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)