SQL Server LEFT() Function
Example
Extract a substring from a string (starting from left):
SELECT LEFT('SQL Tutorial', 3) AS ExtractString;
Try it Yourself »
Definition and Usage
The LEFT() function extracts a substring from a string (starting from left).
Syntax
LEFT(string, number_of_chars)
Parameter Values
Parameter | Description |
---|---|
string | Required. The string to extract from |
number_of_chars | Required. The number of characters to extract |
Note
- If number_of_chars exceeds the number of characters in string, the LEFT() function will return string
Technical Details
Works in: | SQL Server 2014, SQL Server 2012, SQL Server 2008 R2, SQL Server 2008, SQL Server 2005 |
---|
More Examples
Example
Extract a substring from the text in a column (starting from left):
SELECT LEFT(CustomerName, 5) AS ExtractString
FROM Customers;
Try it Yourself »
Example
Extract a substring from a string (starting from left):
SELECT LEFT('SQL Tutorial', 100) AS ExtractString;
Try it Yourself »