Microsoft SQL Server Right


Returns a sub string that is the right most part of the string, with the specified max length.


  1. character expression. The character expression can be of any data type that can be implicitly converted to varchar or nvarchar, except for text or ntext
  2. max length. An integer number between 0 and bigint max value (9,223,372,036,854,775,807). If the max length parameter is negative, an error will be raised.
SELECT RIGHT('This is my string', 6) -- returns 'string'

If the max length is more then the number of characters in the string, the entier string is returned.

SELECT RIGHT('This is my string', 50) -- returns 'This is my string'