Search code examples
.netsql-serverdatetimelocale

Set Locale of a SQL Server 2005


By default the SQL Server comes with the Langauge set to "English (United States)", setting the date format to mm/dd/yy instead of the date format I want it in, which is Australian and has a date format such as dd/mm/yy.

Is there an option in the Server Management Studio / Configuration tools where I can set the locale of the SQL Server, which will prevent the DateTime fields from being formatted in US date format?

If not, how can I convert it when I am using a SQL query such as (forgive me if there is incorrect syntax, I made it up on the spot):

Dim dc As New SqlCommand("INSERT INTO hello VALUES (@Date)", cn)
dc.Parameters.Add(New SqlParameter("Date", System.DateTime.Now))

Many thanks in advance. :)


Solution

  • You can set the default language/locale of each user from SQL Management Studio (look under the Security folder).

    And override this for a specific connection using the SET LANGUAGE command (or SET DATEFORMAT if you just want to change the date format).

    You can also set the default language (used for new users) in SQL Management Studio: right-click on the server, select Properties/Advanced/Default Language.