Convert text in PascalCase

Is it possible to convert text from a table column in SQL Server to PascalCase only using a proper SQL code?

TABLE DEFINITION
----------------------
ID  int
CITTA   varchar(50)
PROV    varchar(50)
CAP varchar(50)
COD varchar(50)

The field that contains text to convert is CITTA. It contains all uppercase values like "ABANO TERME", "ROMA", and so on. The words are delimited by a space.

EDIT

I forgot to mention that some words have an accent character in it '. This character can be found either at the end of the word or in the middle.

EDIT 2:

Some quirks found on results:

  • If I have a name like "ISOLA BALBA" this name get translated to "IsolaBalba" (correct case but missed space)
  • If I have a name like "ISOLA D'ASTI" this get converted to "IsolaD'asti" (missed space as before and incorrect case. In this case the correct result is "Isola D'Asti"

could you please give me some advice on this small problem?

7
задан Lorenzo 8 December 2010 в 03:23
поделиться