|
1 | | ---- |
2 | | -title: "SET LANGUAGE (Transact-SQL)" |
3 | | -description: SET LANGUAGE (Transact-SQL) |
4 | | -author: WilliamDAssafMSFT |
5 | | -ms.author: wiassaf |
6 | | -ms.date: "06/05/2017" |
7 | | -ms.service: sql |
8 | | -ms.subservice: t-sql |
9 | | -ms.topic: reference |
10 | | -f1_keywords: |
11 | | - - "SET_LANGUAGE_TSQL" |
12 | | - - "SET LANGUAGE" |
13 | | -helpviewer_keywords: |
14 | | - - "LANGUAGE option" |
15 | | - - "languages [SQL Server], setting language" |
16 | | - - "SET LANGUAGE statement" |
17 | | - - "options [SQL Server], date" |
18 | | - - "default languages" |
19 | | -dev_langs: |
20 | | - - "TSQL" |
21 | | -monikerRange: "=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current||=fabric" |
22 | | ---- |
23 | | -# SET LANGUAGE (Transact-SQL) |
24 | | -[!INCLUDE [sql-asdb-asdbmi-asa-pdw-fabricse-fabricdw](../../includes/applies-to-version/sql-asdb-asdbmi-asa-fabricse-fabricdw.md)] |
25 | | - |
26 | | - Specifies the language environment for the session. The session language determines the **datetime** formats and system messages. |
27 | | - |
28 | | - |
29 | | - :::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: [Transact-SQL syntax conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md) |
30 | | - |
31 | | -## Syntax |
32 | | - |
33 | | -```syntaxsql |
34 | | - |
35 | | -SET LANGUAGE { [ N ] 'language' | @language_var } |
36 | | -``` |
37 | | - |
38 | | -[!INCLUDE[sql-server-tsql-previous-offline-documentation](../../includes/sql-server-tsql-previous-offline-documentation.md)] |
39 | | - |
40 | | -## Arguments |
41 | | - [**N**]**'**_language_**'** | **@**_language\_var_ |
42 | | - Is the name of the language as stored in [sys.syslanguages](../../relational-databases/system-compatibility-views/sys-syslanguages-transact-sql.md). This argument can be either Unicode or DBCS converted to Unicode. To specify a language in Unicode, use **N'**_language_**'**. If specified as a variable, the variable must be **sysname**. |
43 | | - |
44 | | -## Remarks |
45 | | - The setting of SET LANGUAGE is set at execute or run time and not at parse time. |
46 | | - |
47 | | - SET LANGUAGE implicitly sets the setting of [SET DATEFORMAT](../../t-sql/statements/set-dateformat-transact-sql.md). |
48 | | - |
49 | | -## Permissions |
50 | | - Requires membership in the **public** role. |
51 | | - |
52 | | -## Examples |
53 | | - 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. |
54 | | - |
55 | | -```sql |
56 | | -DECLARE @Today DATETIME; |
57 | | -SET @Today = '12/5/2007'; |
58 | | - |
59 | | -SET LANGUAGE Italian; |
60 | | -SELECT DATENAME(month, @Today) AS 'Month Name'; |
61 | | - |
62 | | -SET LANGUAGE us_english; |
63 | | -SELECT DATENAME(month, @Today) AS 'Month Name' ; |
64 | | -GO |
65 | | -``` |
66 | | - |
67 | | -## See Also |
68 | | - [Data Types (Transact-SQL)](../../t-sql/data-types/data-types-transact-sql.md) |
69 | | - [syslanguages](../../relational-databases/system-compatibility-views/sys-syslanguages-transact-sql.md) |
70 | | - [sp_helplanguage (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-helplanguage-transact-sql.md) |
71 | | - [SET Statements (Transact-SQL)](../../t-sql/statements/set-statements-transact-sql.md) |
72 | | - |
73 | | - |
| 1 | +--- |
| 2 | +title: "SET LANGUAGE (Transact-SQL)" |
| 3 | +description: SET LANGUAGE specifies the language environment for the session. |
| 4 | +author: WilliamDAssafMSFT |
| 5 | +ms.author: wiassaf |
| 6 | +ms.reviewer: randolphwest |
| 7 | +ms.date: 08/30/2024 |
| 8 | +ms.service: sql |
| 9 | +ms.subservice: t-sql |
| 10 | +ms.topic: reference |
| 11 | +f1_keywords: |
| 12 | + - "SET_LANGUAGE_TSQL" |
| 13 | + - "SET LANGUAGE" |
| 14 | +helpviewer_keywords: |
| 15 | + - "LANGUAGE option" |
| 16 | + - "languages [SQL Server], setting language" |
| 17 | + - "SET LANGUAGE statement" |
| 18 | + - "options [SQL Server], date" |
| 19 | + - "default languages" |
| 20 | +dev_langs: |
| 21 | + - "TSQL" |
| 22 | +monikerRange: "=azuresqldb-current || =azure-sqldw-latest || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric" |
| 23 | +--- |
| 24 | +# SET LANGUAGE (Transact-SQL) |
| 25 | + |
| 26 | +[!INCLUDE [sql-asdb-asdbmi-asa-pdw-fabricse-fabricdw](../../includes/applies-to-version/sql-asdb-asdbmi-asa-fabricse-fabricdw.md)] |
| 27 | + |
| 28 | +Specifies the language environment for the session. The session language determines the **datetime** formats and system messages. |
| 29 | + |
| 30 | +:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: [Transact-SQL syntax conventions.](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md) |
| 31 | + |
| 32 | +## Syntax |
| 33 | + |
| 34 | +```syntaxsql |
| 35 | +SET LANGUAGE { [ N ] 'language' | @language_var } |
| 36 | +``` |
| 37 | + |
| 38 | +[!INCLUDE [sql-server-tsql-previous-offline-documentation](../../includes/sql-server-tsql-previous-offline-documentation.md)] |
| 39 | + |
| 40 | +## Arguments |
| 41 | + |
| 42 | +#### [N]'*language*' | @*language_var* |
| 43 | + |
| 44 | +The name of the language as stored in [sys.syslanguages](../../relational-databases/system-compatibility-views/sys-syslanguages-transact-sql.md). This argument can be either Unicode or DBCS converted to Unicode. To specify a language in Unicode, use `N'<language>'`. If specified as a variable, the variable must be **sysname**. |
| 45 | + |
| 46 | +## Remarks |
| 47 | + |
| 48 | +The setting of `SET LANGUAGE` is set at execute or run time and not at parse time. |
| 49 | + |
| 50 | +`SET LANGUAGE` implicitly sets the setting of [SET DATEFORMAT](set-dateformat-transact-sql.md). |
| 51 | + |
| 52 | +## Permissions |
| 53 | + |
| 54 | +Requires membership in the **public** role. |
| 55 | + |
| 56 | +## Examples |
| 57 | + |
| 58 | +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. |
| 59 | + |
| 60 | +```sql |
| 61 | +DECLARE @Today DATETIME; |
| 62 | +SET @Today = '2024-08-05'; |
| 63 | + |
| 64 | +SET LANGUAGE Italian; |
| 65 | +SELECT DATENAME(month, @Today) AS 'Month Name'; |
| 66 | + |
| 67 | +SET LANGUAGE us_english; |
| 68 | +SELECT DATENAME(month, @Today) AS 'Month Name'; |
| 69 | +GO |
| 70 | +``` |
| 71 | + |
| 72 | +## Related content |
| 73 | + |
| 74 | +- [Data types (Transact-SQL)](../data-types/data-types-transact-sql.md) |
| 75 | +- [syslanguages](../../relational-databases/system-compatibility-views/sys-syslanguages-transact-sql.md) |
| 76 | +- [sp_helplanguage (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-helplanguage-transact-sql.md) |
| 77 | +- [SET Statements (Transact-SQL)](set-statements-transact-sql.md) |
0 commit comments