Vinodtiru Vinodtiru - 6 months ago 25
SQL Question

How to get first character of a string in SQL?

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

Answer

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.

Comments