In this tutorial, I am going to explain you SQL-Server built-in String functions with example. Below is the list of most commonly used SQL-Server System defined String function.
We will discuss in this article | We will discuss in next article |
|
|
---|
Below is explanation for each function.
ASCII Function
Syntax:ASCII( Character_Expression )Description:It is used to return ASCII code of the supplied character expression.Input expression can be char or varchar.It returns ASCII code of first character from left hand side.It does opposite of CHAR function.Example:
CHAR Function
Syntax:ASCII( Integer_Expression )Description:It is used to convert an int ASCII code to a character.Input should be between 0 and 255.It does opposite of ASCII function.Example:
UPPER Function
Syntax:UPPER ( character_expression )Description:It is used to convert character expression into upper case character.Example:
LOWER Function
Syntax:LOWER ( character_expression )Description:It is used to convert character expression into lower case character.Example:
LTRIM Function
Syntax:LTRIM ( character_expression )Description:It is used to remove spaces from left side of character expression.Example:
RTRIM Function
Syntax:RTRIM ( character_expression )Description:It is used to remove spaces from right side of character expression.Example:
REVERSE Function
Syntax:REVERSE ( string_expression )Description:It is used to reverse the order of supplied string.Example:
LEN Function
Syntax:REVERSE ( string_expression )Description:It is used to count total characters in the supplied string expression.It excludes the spaces at the end of the expression (right hand side).Example:
LEFT Function
Syntax:LEFT ( character_expression , integer_expression ) Description:It is used to return the specified number of characters from the left hand side of the supplied character expression.Example:
RIGHT Function
Syntax:RIGHT ( character_expression , integer_expression ) Description:It is used to return the specified number of characters from the right hand side of the supplied character expression.Example: