How to get first character of a string in SQL?

Vinod picture Vinod · Apr 27, 2009 · Viewed 691.6k times · Source

I have a SQL column with a length of 6. Now want to take only the first char of that column. Is there any string function in SQL to do this?

Answer

Eric picture Eric · Apr 27, 2009

LEFT(colName, 1) will also do this, also. It's equivalent to SUBSTRING(colName, 1, 1).

I like LEFT, since I find it a bit cleaner, but really, there's no difference either way.