The LOWER() and UPPER() Functions : UPPER « String Functions « SQL Server / T-SQL Tutorial






5> DECLARE @LastName VarChar(25), @SpaceIndex TinyInt
6> SET @LastName = 'mc donald'
7> -- Find space in name:
8> SET @SpaceIndex = CHARINDEX(' ', @LastName)
9> IF @SpaceIndex > 0                      
10> SELECT UPPER(LEFT(@LastName, 1))
11> + LOWER(SUBSTRING(@LastName, 2, @SpaceIndex - 1))
12> + UPPER(SUBSTRING(@LastName, @SpaceIndex + 1, 1))
13> + LOWER(SUBSTRING(@LastName, @SpaceIndex + 2, LEN(@LastName)))
14> ELSE                                   
15> SELECT UPPER(LEFT(@LastName, 1))
16> + LOWER(SUBSTRING(@LastName, 2, LEN(@LastName)))
17> GO

----------------------------------------------------
Mc Donald

(1 rows affected)
1>








12.24.UPPER
12.24.1.UPPER Translates all characters within the string to upper case.
12.24.2.The LOWER() and UPPER() Functions
12.24.3.select UPPER('ca')
12.24.4.Changing Character Values to Upper