Client-facing applications which require that a user choose say, a month or weekday name from a list usually rely on hard-coded lists or by the values in a table, config file, or other location.  Unless the original design allows for multiple languages, it can easily get messy when extending the functionality.

A database developer has another option in this case - use the lists already built into SQL Server.  This information is stored in the sys.syslanguages (Transact-SQL) compatibility view and can also be retrieved using the sp_helplanguage (Transact-SQL) stored procedure.  Most notably are the months, shortmonths and days columns.  These columns are stored as comma-delimited values and since the permission defaults to the public role, they can be retrieved by all authenticated logins.  What is interesting is that the view or stored procedure can return the values in one of the installed languages (see sys.syslanguages documentation).

The following script can be used as a proof of concept.  It uses the T-SQL fn_split function whose object definition can be found at the end of this article (truthfully, I didn’t write this version of the fn_split function and unfortunately I cannot recall from where I got it, but I’m sharing anyway).  In the below sample I tested the script using three different langauges.

--SET LANGUAGE us_english

DECLARE @months nvarchar(372),
        @shortmonths varchar(132),
        @days nvarchar(217);

SELECT @months = [months], @shortmonths = [shortmonths], @days = [days]
FROM [master].[sys].[syslanguages]
WHERE [name] = @@LANGUAGE;

PRINT @months;
PRINT @shortmonths;
PRINT @days;
Le paramètre de langue est passé à Français.
L'impostazione della lingua è stata sostituita con Italiano.
Changed language setting to us_english.

SELECT ReturnCol AS [Months] FROM [db_dba].dbo.fn_split(@months, ',');
SELECT ReturnCol AS [ShortMonths] FROM [db_dba].dbo.fn_split(@shortmonths, ',');
SELECT ReturnCol AS [Days] FROM [db_dba].dbo.fn_split(@days, ',');

The above is an example of reusing what is already persent in the DBMS without having to “reinvent the wheel”.

The script for the fn_split function can be downloaded here.