SQL Server: LEFT String Functions in SQL Server



Left: This function use when we want to select a left part of the character string with the specified number of characters.

Syntax:

LEFT ( character_expression , integer_expression )

character_expression: Character expression is the expression of character or binary data, except text or ntext, character_expression can be of any data type.

integer_expression: integer_expression is a positive integer that specifies how many characters of the character_expression will be returned.

For example:

DECLARE @str VARCHAR(60)  

SET @str='dilip Kumar Singh'

select Left(@str,5) AS LeftFiveChar



Result:

LeftFiveChar

------------

dilip


(1 row(s) affected)

Related Posts

Fatal Error: Peer authentication failed for user "postgres", when trying to get pgsql working with rails.

Problem: Sometimes, we get the following error when trying to make a connection in Rails.  FATAL ERROR: Peer authentication failed for us...