SQL Server: RIGHT Function

RIGHT function

This SQL Server tutorial explains how to use the RIGHT function in SQL Server (Transact-SQL) with syntax and examples.


In SQL Server (Transact-SQL), the RIGHT function allows you to extract a substring from a string, starting from the right-most character.


The syntax for the RIGHT function in SQL Server (Transact-SQL) is:

RIGHT( string, number_of_characters )

Parameters or Arguments


The string that you wish to extract from.


The number of characters that you wish to extract starting from the right-most character.


  • If the number_of_characters exceeds the length of the string, the RIGHT functions will return string.

Applies To

The RIGHT functions can be used in the following versions of SQL Server (Transact-SQL):

  • SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008 R2, SQL Server 2008, SQL Server 2005


Let’s look at some SQL Server RIGHT functions examples and explore how to use the RIGHT functions in SQL Server (Transact-SQL).

For example:

SELECT RIGHT('adglob.in', 6);
Result: 'lob.in'

SELECT RIGHT('adglob.in', 4);
Result: 'b.in'

SELECT RIGHT('adg lob', 100);
Result: 'adg lob'   

Leave a Reply