2

I have a table Vendors that contains a column VendorContactFname, which is written in lowercase.

I want to capitalize only its first letter. I am thinking of concatenating an Upper on the first letter to the left, with all other remaining letters to its right in their original lower case, i.e., with the substring:

Upper(Left(VendorContactFname,1) ) + 
Substring('VendorContactFName',2, Len('contactFname')-1 ) 

Is there a better way to do this?

0

1 Answer 1

8

Another way is to use STUFF to replace the first character directly:

-- Demo
SELECT
    STUFF
    (
        O.name,
        1, 1,
        UPPER(LEFT(O.name, 1))
    )
FROM sys.objects AS O;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.