Pages

Thursday, March 22, 2012

How to find out default language & default database settings?


Execute the following Microsoft SQL Server T-SQL scripts in Management Studio Query Editor to demonstrate the getting and setting of default language and default database:

-- Find out default language
SELECT @@language
------------

-- Find out default database
SELECT loginname as LoginName,
       dbname as DefaultDatabase,
       DATABASEPROPERTYEX(dbname, 'Status') as DatabaseStatus
FROM sys.syslogins
ORDER BY LoginName
------------
-- Get all languages information
EXEC sp_helplanguage
------------

-- Setting default language for login
use master

EXEC sp_defaultlanguage 'kimberlyhay', 'us_english'
GO


-- SQL Server 2005 and onward
ALTER LOGIN kimberlyhay WITH DEFAULT_LANGUAGE = British;
GO


-- Languages in SQL Server 2008 with dateformat
SELECT LanguageID = langid,
       name,
       alias,
       dateformat
FROM     sys.syslanguages
ORDER BY langid
GO
-- Results
LanguageIDnamealiasdateformat
0us_englishEnglishmdy
1DeutschGermandmy
2FrançaisFrenchdmy
3日本語Japaneseymd
4DanskDanishdmy
5EspañolSpanishdmy
6ItalianoItaliandmy
7NederlandsDutchdmy
8NorskNorwegiandmy
9PortuguêsPortuguesedmy
10SuomiFinnishdmy
11SvenskaSwedishymd
12češtinaCzechdmy
13magyarHungarianymd
14polskiPolishdmy
15românăRomaniandmy
16hrvatskiCroatianymd
17slovenčinaSlovakdmy
18slovenskiSloveniandmy
19ελληνικάGreekdmy
20българскиBulgariandmy
21русскийRussiandmy
22TürkçeTurkishdmy
23BritishBritish Englishdmy
24eestiEstoniandmy
25latviešuLatvianymd
26lietuviųLithuanianymd
27Português (Brasil)Braziliandmy
28繁體中文Traditional Chineseymd
29한국어Koreanymd
30简体中文Simplified Chineseymd
31ArabicArabicdmy
32ไทยThaidmy
------------

-- Setting default database for login
EXEC sp_defaultdb 'kimberlyhay', 'AdventureWorks'

-- SQL Server 2005 and SQL Server 2008
ALTER LOGIN kimberlyhay WITH DEFAULT_DATABASE = AdventureWorks2008;
------------

No comments:

Post a Comment