How to get the first character of a string in SQL Server ?

Assume a scenario where you have a column in your table in SQL Server database where you want to retreive the first character of the column value.

How to get the first character of a string in SQL Server ?

You can use the LEFT function and specify the column name as well as the number of characters from left that you want to retreive.

Use AdventureWorks2014
GO    
SELECT LEFT(Name,1) as FirstCharacter from HumanResources.Department
image

Leave Your Comment

Liked this content?. Please spread the word :)