Extract the last 4 characters from a string.
SELECT Right(“SQL Tutorial is cool”, 4) AS ExtractString; |
The Right() function extracts a specified number of characters from the end of a string.
Note: See also the Left() function.
Right(string, number_of_chars) |
Parameter |
Description |
string |
Required. The string to extract characters from. |
Number_of_char |
Required. Specifies the number of characters to extract. If this number exceeds the length of the string, the function will return the entire string. |
Works in: |
From Access 2000 |
Extract the last 5 characters from the text in the “CustomerName” column.
SELECT Right(CustomerName, 5) AS ExtractString FROM Customers; |