sqlsql-serversql-server-2005

How to get first character of a string in SQL?


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?


Solution

  • 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.