LEFT (Transact-SQL)
Returns the left part of a character string with the specified number of characters.
Compatibility levels can affect return values. For more information about compatibility levels, see sp_dbcmptlevel (Transact-SQL).
A. Using LEFT with a column
The following example returns the five leftmost characters of each product name.
USE AdventureWorks; GO SELECT LEFT(Name, 5) FROM Production.Product ORDER BY ProductID; GO
B. Using LEFT with a character string
The following example uses LEFT to return the two leftmost characters of the character string abcdefg.
SELECT LEFT('abcdefg',2)
GO
Here is the result set.
-- ab (1 row(s) affected)
