Reputation: 105
I have column that contains many row. Each row has value about 3 words. I want to change first letter of that value into upper case. Only first letter, example abc def ghi into Abc def ghi. Please help me. Thank !!
Upvotes: 2
Views: 5499
Reputation: 279
Also this worked
DECLARE @val VARCHAR(20) = 'abc def ghi'
SELECT UPPER(SUBSTRING(@val,1,1))+SUBSTRING(@val,2,LEN(@val)-1)
Upvotes: 0
Reputation: 105
DONE !! thx all
UPDATE table SET column= CONCAT(upper(LEFT(column, 1)),
SUBSTRING(column, 2,100));
Upvotes: 2
Reputation: 1464
You can try this:
DECLARE @val VARCHAR(100) = 'abc def'
SELECT UPPER(LEFT(@val,1)) + SUBSTRING(@val,2,LEN(@val))
Upvotes: 1
Reputation: 9063
You can use LEFT
and RIGHT
in following:
DECLARE @val VARCHAR(100) = 'abc def ghi'
SELECT UPPER(LEFT(@val,1)) + RIGHT(@val, LEN(@val) -1)
Upvotes: 1
Reputation: 9890
Since you only want only first character in caps, You can use STUFF
with UPPER
and LEFT
like this
DECLARE @val VARCHAR(100) = 'abc def ghi'
SELECT STUFF(@Val,1,1,UPPER(LEFT(@Val,1)))
OUTPUT
Abc def ghi
Note: If you have spaces at the start of the string use LTRIM
before other operations
Upvotes: 4