Returns a specified number of characters on the left end of a character string.
left(character_expression, integer_expression)
is the character string from which the characters on the left are selected.
is the positive integer that specifies the number of characters returned. An error is returned if integer_expression is negative.
Returns the five leftmost characters of each book title.
use pubs select left(title, 5) from titles order by title_id ----- The B Cooki You C ..... Sushi (18 row(s) affected)
Returns the two leftmost characters of the character string "abcdef".
select left("abcdef", 2) --------- ab (1 row(s) affected)
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). For more information on this function, see substring.
ANSI SQL – Compliance level: Transact-SQL extension.
Any user can execute left.
Functions len, str_replace, substring
Copyright © 2005. Sybase Inc. All rights reserved. |