Right Example 1:
SELECT RIGHT ('zxcvbnm',3);
Result: bnm
SELECT RIGHT ('12345',2);
Result: 45
SELECT RIGHT (78901,2);
Result: 01
SELECT RIGHT ('1a2b3c',4);
Result: 2b3c
Right Example 2:
Cities table:
| CITY_ID | NAME | STATE |
|---|---|---|
| 1 | New York | New York |
| 2 | Los Angeles | California |
| 3 | Chicago | Illinois |
| 4 | San Antonio | Texas |
| 5 | San Diego | California |
SELECT RIGHT (name, 4) AS Result
FROM cities WHERE city_id=1;
Right Result:
| Result |
|---|
| York |
See also: T-SQL Functions -> Substring | Right | Rtrim | Upper | Left | LTRIM