When a new login is created in SQL Server, it is assigned a default language. This language is used for system messages and date/time formats. This language will be used as the default language whenever that login connects to SQL Server (but it can also be changed to a different language within the session).
If you ever wish to find out the language that’s assigned to the current session, you can run one of the options on this page.
Option 1: The @@LANGUAGE Configuration Function
The first option for getting the language of the current session is to use the @@LANGUAGE
scalar function. Simply use it as part of a SELECT
statement.
Like this:
SELECT @@LANGUAGE;
Result:
us_english
Option 2: The DBCC USEROPTIONS Command
You can also run DBCC USEROPTIONS
to return the current language, as well as other options for the current connection.
Like this:
DBCC USEROPTIONS;
Result:
+-------------------------+----------------+ | Set Option | Value | |-------------------------+----------------| | textsize | -1 | | language | us_english | | dateformat | mdy | | datefirst | 7 | | lock_timeout | 5000 | | quoted_identifier | SET | | arithabort | SET | | ansi_null_dflt_on | SET | | ansi_warnings | SET | | ansi_padding | SET | | ansi_nulls | SET | | concat_null_yields_null | SET | | isolation level | read committed | +-------------------------+----------------+
Option 3: The sys.dm_exec_requests View
This option is a bit different to the previous two options in that this system view returns information at the individual request level (it returns information about each request that’s executing in SQL Server). You can narrow it down to the current request (which will be the SELECT
statement with which you query the view).
This view returns a relatively large number of columns, so if you’re only interested in the language, you can select just that column.
Here’s how to return the language being used in the current user process:
SELECT r.language FROM master.sys.dm_exec_requests r WHERE r.session_id = @@SPID;
Result:
+------------+ | language | |------------| | us_english | +------------+
You can always change the language for the current session. To find out how, see How to Set the Current Language in SQL Server (T-SQL).
Also note that some inbuilt T-SQL functions accept arguments to specify the language/culture to be used at the specific query level. For example the PARSE()
function allows you to specify a culture to use for the query (or even part of the query) that specifies how the given string is formatted (for an example, see How to Convert a String to a Date/Time in SQL Server using PARSE()).
The Default Language
Note that a user can also have a default language that is different to the current language. If they use the SET LANGUAGE
statement to change to another language, their default language will remain as their default language, even though the language of the current session has changed.
To find the default language for a user/login/role, see How to Find a User’s Default Language in SQL Server (T-SQL).