2 Ways to Get the Default Language of a Login in SQL Server (T-SQL)

There are (at least) a couple of ways you can use T-SQL to return the default language of a specified login in SQL Server.

In particular, you can use the following methods:

  • Query the LOGINPROPERTY() function.
  • Query the sys.server_principals system catalog view in the master database.

Examples of these are below.

The LOGINPROPERTY() Function

The LOGINPROPERTY() function requires a login name and a property to be passed to it as arguments. It then produces its result based on those arguments.

Here’s an example.

SELECT LOGINPROPERTY('Bart', 'DefaultLanguage');

Result:

us_english

The sys.server_principals View

An alternative way to do it is to use the sys.server_principals system catalog view.

This view returns more columns than we need, so we can specify which columns we want returned.

We should also specify the login we want to return, otherwise we’ll get all logins (although there’s nothing wrong with that, if that’s what you need to do).

SELECT 
    default_language_name 
FROM master.sys.server_principals
WHERE name = 'Bart';

Result:

us_english

One benefit of using this view is that it’s easy to include other columns, such as the default database name, etc.

SELECT 
    type_desc,
    default_database_name,
    default_language_name 
FROM master.sys.server_principals
WHERE name = 'Bart';

Result:

+-------------+-------------------------+-------------------------+
 | type_desc   | default_database_name   | default_language_name   |
 |-------------+-------------------------+-------------------------|
 | SQL_LOGIN   | master                  | us_english              |
 +-------------+-------------------------+-------------------------+