Strings

INITCAP

Capitalises the first letter of every word and makes the rest lowercase.

Syntax

INITCAP(<text>)

Handy for tidying up names and titles typed any old way: emma WILSON becomes Emma Wilson. A word is anything between non-letter characters: spaces, hyphens, apostrophes.

Data for the examples

employees

namedepartmentsalarybonusphone
Emmabackend1200300+44 7700 900123
Liambackend1000NULLNULL
Oliviafrontend1350150+44 7700 900456
Noahfrontend950NULL+44 7700 900789
Sophiadesign1200200NULL

These tables already exist in the sandbox — the examples below use them. Want to try this in your own database? Copy the SQL.

Tidying up a name
SELECT INITCAP('emma WILSON') AS full_name;
full_name
Emma Wilson
Department names capitalised
SELECT DISTINCT INITCAP(department) AS department
FROM employees
ORDER BY department;
department
Backend
Design
Frontend

Watch out

It knows nothing about language rules: INITCAP('o''brien mcdonald') gives O'Brien Mcdonald, and INITCAP('iPhone') gives Iphone.

A hyphen separates words too: INITCAP('e-mail') gives E-Mail.

Related functions