0

I would like to camel case the values of my records in SQL. However, the values contain special characters such as '/' and '.' - for example, I have values such as "U.s.a" and "USA/UK".

In the example of "U.s.a" the result should be "U.S.A".

In the example of "USA/UK" the result should be "Usa/Uk".

I hope the above makes sense. I would really appreciate any assistance.

Thank you in advance.

sqlenthusiast
  • 165
  • 3
  • 12
  • What options have you considered and tried? – Dale K Jan 28 '21 at 00:57
  • Hi @DaleK I have tried UPPER(LEFT([field], 1)) + LOWER(SUBSTRING([field], 2, LEN([field]))) AS [field] - this is only capitalizing the first word in the string. – sqlenthusiast Jan 28 '21 at 01:01
  • Very difficult to do in T-SQL. You basically need a word split and detect all non alphanumeric as a word break. There is a bodgy solution involving cross applying a tally table and pulling out single character substrings. A scalar function might be another option – Charlieface Jan 28 '21 at 01:03
  • Personally I do any complex string manipulation in C# using CLR functions. – Dale K Jan 28 '21 at 01:07
  • @Charlieface I am still finding my feet in the world of data - started off with SQL. I have been searching for a while but have not come across anything yet to solve my challenge. – sqlenthusiast Jan 28 '21 at 01:15

0 Answers0