Função para tornar a primeira letra em maiúsculo (first letter capitalized - upper)

CREATE FUNCTION fn_RightCase (@Nome VARCHAR(100)) RETURNS Varchar(100) AS
BEGIN
DECLARE @strtemp VARCHAR(100)
DECLARE @i INT
SET @strtemp = LOWER(@Nome)
SET @strtemp = UPPER(LEFT(@strtemp,1)) +
SUBSTRING(@strtemp,2,LEN(@strtemp))
WHILE CHARINDEX(‘ ‘,@strtemp,1) > 0
BEGIN
SET @i = CHARINDEX(‘ ‘,@strtemp,1)
SET @strtemp = LEFT(@strtemp,@i-1) + ‘|’ +
UPPER(SUBSTRING(@strtemp,@i + 1,1)) +SUBSTRING(@strtemp,@i+2,LEN(@strtemp))
END
SET @strtemp = REPLACE(@strtemp,’|’,’ ‘)
SET @Nome = @strtemp
RETURN @Nome
END