SQL Server – Difference between LEFT and RIGHT function with example

 
SQL Server LEFT and RIGHT function fetches number character from expression, LEFT function use to fetch LEFT side value whereas RIGHT function gives value from RIGHT side of expression.

LEFT vs RIGHT function in sql server

SQL Server LEFT  function returns character and Takes two parameter, first parameter is string value or any expression and another specify the number of character to be fetch from expression. RIGHT function returns RIGHT side value

Syntax :

LEFT(‘Input_value’,number_character)
RIGHT(‘Input_value’,number_character)
Input Value can be anything. Second parameter must be number that indicates number of character.

Example

Below example will give you the idea how and when to use RIGHT and LEFT function of sql server
SELECT LEFT(‘Football’,4) as ‘Result of LEFT function’
SELECT RIGHT(‘Football’,4) as ‘Result of RIGHT function’

Output

Result of LEFT function
———————–
Foot
Result of RIGHT function
————————
ball

Leave a Reply

  

  

  


− 1 = 1