Extracts a certain number of characters from the leading portion of a string value.
Syntax
LEFT(<StringExpression> FOR <IntegerExpression>)
LEFT(<StringExpression>, <IntegerExpression>)
<StringExpression> =
Type of:
CHARACTER|CHAR
CHARACTER VARYING|VARCHAR
GUID
CHARACTER LARGE OBJECT|CLOB
Returns
Same as input
UsageThe LEFT function extracts a certain number of characters from the leading portion of a string. The FOR parameter specifies the length of the extracted substring. If the FOR parameter is greater than the length of the input string, then the result will be the input string.
Examples
SELECT LEFT(CustomerID, 6)
FROM Customers
SQL 2003 Standard DeviationsThis function deviates from the SQL 2003 standard in the following ways: