Wednesday, 22 June 2011

Using comma-delimited lists in SQL searches

Today I wanted to run a search against a comma-delimited list of values, a little like this:
Select name from People Where category IN ('N,S,L,C')
I wanted the comma-delimited list to be set as a parameter value in a stored procedure. However, the IN operator cannot accept a comma-delimited string. It only accepts comma-delimited constants or the results of a SQL query.

Eventually I found this excellent solution on the 4 Guys site. It shows you how to build a UDF (user-defined function) that will split a comma-delimted string into a recordset representation, and then how to make use of it. It's a neat and effective solution.

Wednesday, 8 June 2011

Language code

The following table lists all the possible language codes used to specify various system settings.

afAfrikaans sqAlbanian
ar-saArabic (Saudi Arabia) ar-iqArabic (Iraq)
ar-egArabic (Egypt) ar-lyArabic (Libya)
ar-dzArabic (Algeria) ar-maArabic (Morocco)
ar-tnArabic (Tunisia) ar-omArabic (Oman)
ar-yeArabic (Yemen) ar-syArabic (Syria)
ar-joArabic (Jordan) ar-lbArabic (Lebanon)
ar-kwArabic (Kuwait) ar-aeArabic (U.A.E.)
ar-bhArabic (Bahrain) ar-qaArabic (Qatar)
euBasque bgBulgarian
beBelarusian caCatalan
zh-twChinese (Taiwan) zh-cnChinese (PRC)
zh-hkChinese (Hong Kong SAR) zh-sgChinese (Singapore)
hrCroatian csCzech
daDanish nlDutch (Standard)
nl-beDutch (Belgium) enEnglish
en-usEnglish (United States) en-gbEnglish (United Kingdom)
en-auEnglish (Australia) en-caEnglish (Canada)
en-nzEnglish (New Zealand) en-ieEnglish (Ireland)
en-zaEnglish (South Africa) en-jmEnglish (Jamaica)
enEnglish (Caribbean) en-bzEnglish (Belize)
en-ttEnglish (Trinidad) etEstonian
foFaeroese faFarsi
fiFinnish frFrench (Standard)
fr-beFrench (Belgium) fr-caFrench (Canada)
fr-chFrench (Switzerland) fr-luFrench (Luxembourg)
gdGaelic (Scotland) gaIrish
deGerman (Standard) de-chGerman (Switzerland)
de-atGerman (Austria) de-luGerman (Luxembourg)
de-liGerman (Liechtenstein) elGreek
heHebrew hiHindi
huHungarian isIcelandic
idIndonesian itItalian (Standard)
it-chItalian (Switzerland) jaJapanese
koKorean koKorean (Johab)
lvLatvian ltLithuanian
mkMacedonian (FYROM)msMalaysian
mtMaltese noNorwegian (Bokmal)
noNorwegian (Nynorsk) plPolish
pt-brPortuguese (Brazil) ptPortuguese (Portugal)
rmRhaeto-Romanic roRomanian
ro-moRomanian (Republic of Moldova) ruRussian
ru-moRussian (Republic of Moldova) szSami (Lappish)
srSerbian (Cyrillic) srSerbian (Latin)
skSlovak slSlovenian
sbSorbian esSpanish (Spain)
es-mxSpanish (Mexico) es-gtSpanish (Guatemala)
es-crSpanish (Costa Rica) es-paSpanish (Panama)
es-doSpanish (Dominican Republic) es-veSpanish (Venezuela)
es-coSpanish (Colombia) es-peSpanish (Peru)
es-arSpanish (Argentina) es-ecSpanish (Ecuador)
es-clSpanish (Chile) es-uySpanish (Uruguay)
es-pySpanish (Paraguay) es-boSpanish (Bolivia)
es-svSpanish (El Salvador) es-hnSpanish (Honduras)
es-niSpanish (Nicaragua) es-prSpanish (Puerto Rico)
sxSutu svSwedish
sv-fiSwedish (Finland) thThai
tsTsonga tnTswana
trTurkish ukUkrainian
urUrdu veVenda
viVietnamese xhXhosa
jiYiddish zuZulu