Thursday, December 1, 2011

Capitalize the first character

Function :

CREATE FUNCTION InitCapital (
@string varchar(255)
)
RETURNS varchar(255) AS
BEGIN

RETURN upper(left(@string, 1)) + right(@string, len(@string) - 1)

END

Query :

SELECT
InitCapital(Left(user_name, CHARINDEX('.', user_name, 1) - 1)) as First_Name,
InitCapital(Right(user_name, (Len(id_user) - CHARINDEX('.', user_name, 1)))), as Last_Name,
username,
FROM tblUsers

No comments:

Post a Comment