left

Returns a specified number of characters on the left end of a character string.

Syntax

left(character_expression, integer_expression)

Parameters

Examples

Usage

  • character_expression can be of any datatype (except text or image) that can be implicitly converted to varchar or nvarchar. character_expression can be a constant, variable, or a column name. You can explicitly convert character_expression using convert.

  • left is equivalent to substring(character_expression, 1, integer_expression).

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

Any user can execute left.

Related concepts
Transact-SQL Functions
Related reference
len
str_replace
substring