kSQL 

T-SQL: Capitalize First Character in a String

First, thanks to Hipster Ipsum for providing really fun random string data! I created a proc this week that was a simple SELECT ALL from a lookup and the output was going to be used in a drop down menu in a Reporting Services report. The data wasn't the prettiest and I wanted to capitalize the first letter of every item within my SELECT without using a function. Here is how I did it:

CREATE TABLE #StringData(StringData VARCHAR(100));

INSERT INTO #StringData(StringData) 

VALUES ('High life truffaut artisan salvia'), ('raw denim tofu terry richardson skateboard'), ('iphone PickLED'), ('BOOTH SQUID'), (' ')

SELECT UPPER(LEFT(StringData,1)) + RIGHT(StringData,(LEN(StringData)-1)) AS 'With Capital',

StringData AS 'Original' 

FROM #StringData 

WHERE LEN(StringData) > 0

UNION

SELECT ''AS 'With Capital',

StringData AS 'Original' 

FROM #StringData 

WHERE LEN(StringData) = 0

The output is below: it works in every case except a string with a length of 0.