I wrote a function so that the first letter of the entered username is capitalized and all letters of the last name are capitalized.
The code I tried:
CREATE FUNCTION fn_capitalized(@name varchar(20), @surname varchar(20))
RETURNS VARCHAR(41)
AS
BEGIN
DECLARE @result varchar(41)
SET @result = UPPER(SUBSTRING(@name,1,1)) + LOWER(SUBSTRING(@name,2,LEN(@name))) + ' ' + UPPER(@surname)
RETURN @result
END
But if user has 2 or more names how can I capitalize their other name
For example: select dbo.fn_xx('john jack','david')