SQL query to capitalize the first and last character to uppercase and the remain in lower case using CONCAT function of SQL Server 2012

Rajnilari2015
Posted by Rajnilari2015 under Sql Server category on | Points: 40 | Views : 1097
DECLARE @T Table(Name Varchar(20))
INSERT INTO @T
SELECT 'karurkit' UNION ALL
SELECT 'ranjha' UNION ALL
SELECT 'sebanintian'

SELECT
OriginalName =Name
,ModifiedName=CONCAT(UPPER(LEFT(Name,1)),SUBSTRING(NAME, 2, LEN(Name)-2),UPPER(RIGHT(NAME,1)))
FROM @T


Output
---------


OriginalName	ModifiedName
karurkit KarurkiT
ranjha RanjhA
sebanintian SebanintiaN

Comments or Responses

Login to post response