The INITCAP Function

Moderator: NorbertKrupa

Post Reply
User avatar
JimKnicely
Site Admin
Site Admin
Posts: 1825
Joined: Sat Jan 21, 2012 4:58 am
Contact:

The INITCAP Function

Post by JimKnicely » Fri Aug 10, 2012 1:00 pm

Vertica includes a handy string function named INITCAP that will capitalize the first letter of each alphanumeric word and put the rest in lowercase for a given text string.

Examples:

Code: Select all

dbadmin=> select initcap('siu peng chan, jim knicely, tom light');
                initcap
---------------------------------------
Siu Peng Chan, Jim Knicely, Tom Light

Code: Select all

dbadmin=> select initcap('please capitalize the first letter of every word in this sentence. why? i don''t know...');
                                         initcap
-----------------------------------------------------------------------------------------
Please Capitalize The First Letter Of Every Word In This Sentence. Why? I Don't Know...
(1 row)

dbadmin=> select initcap('but you can''t do this in mysql or sql server without writing your own crazy function :)');
                                         initcap
-----------------------------------------------------------------------------------------
But You Can't Do This In Mysql Or Sql Server Without Writing Your Own Crazy Function :)
(1 row)
Have fun
Jim Knicely

Image

Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.

Post Reply

Return to “Vertica Tips, Lessons and Examples”