Getting the SQL Server default language display name or alias from server.Configuration.DefaultLanguage.ConfigValue using SMO.

When using SQL server management studio you see the default language for the server.



When using SMO you can access this using the following code, however this returns an integer value.

server.Configuration.DefaultLanguage.ConfigValue;

Unlike SQL databases where you can view the LCID of the language the default language of the SQL server using a LangID value. You can see the LangID and the corresponding LCID by running the following query in SQL.

SELECT * FROM sys.syslanguages


But there's also an easy way to get this directly within SMO using the server.Languages property.

/// <summary>
///
Returns the alias for the language with the specified LangID.

/// </summary>
///
<param name="langID">The unique identifier of the language for which the alias is to be returned.</param>
///
<returns>The alias for the language with the specified LangID.</returns>
private
String GetLanguageAlias(int langID)
{

   
foreach (Language language in nativeServer.Languages) { if (language.LangID == langID) { return language.Alias; } }
return
String.Empty;
}



For more information about documenting SQL Server see our XIA Configuration Server page!



Comments

Popular posts from this blog

SOLVED: Exchange Online Management PowerShell Connect-ExchangeOnline bug "A window handle must be configured. See https://aka.ms/msal-net-wam#parent-window-handles"

Windows Server 2016, 2019, 2022, Windows 10 and Windows 11: Date and time "Some settings are managed by your organization".

get-windowsfeature : The given key was not present in the dictionary