T-SQL Tutorial

T-SQL Left function


Left Example 1:

SELECT LEFT ('abcdefghik',3);
Result: abc

SELECT LEFT ('12345',2);
Result: 12

SELECT LEFT (17345,2);
Result: 17

SELECT LEFT ('1a2b3c',4);
Result: 1a2b

Left Example 2:

Cities table:

CITY_IDNAMESTATE
1New YorkNew York
2Los AngelesCalifornia
3ChicagoIllinois
4San AntonioTexas
5San DiegoCalifornia

SELECT LEFT (name, 3) AS Result
FROM cities
WHERE state='California';

Left Result:

Result
Los
San

See also: T-SQL Functions -> Right | LTRIM | RTRIM