LEFT Function

Returns a substring of a string from the beginning.

Overview

The LEFT function extracts a specified number of characters from the beginning of a string.

It is a string function and returns a string value.

Syntax

LEFT ( string, number )

Parameters

Return Value

A string containing the specified number of characters from the beginning of the input string. If the input string is shorter than the specified number of characters, the function returns the entire input string.

Examples

Example 1

SELECT LEFT ('Hello World', 5); -- Returns 'Hello'

Example 2

SELECT LEFT ( 'SQL Server', 6 ); -- Returns 'SQL Ser'

Example 3

SELECT LEFT ( 'Short', 10); -- Returns 'Short'