SQL String Functions

The SQL Server provides various String Functions. These string functions allow us to alter the individual characters in a string, compare two, search for a substring, extract substrings, and copy a string. You can also use these SQL String Functions to convert them to lowercase or uppercase.

A string is a group of charters stored in Varchar or Nvarchar data type, which is useful to store names, product descriptions, etc. SQL String functions enable you to manipulate the string data by searching for the given substring and replacing it or adding so on. This article shows you the available list of SQL string functions and their definitions.

SQL String Functions

The following table will show you the list of available SQL String Functions. Use those links to see the practical example for each one of the string functions.

ASCIIIt returns the ASCII code of the leftmost character of a character expression.
CHARConvert the integer value (ASCII code) to a character
CHARINDEXIt returns the index position of a specified expression
CONCATCombine or concatenate two or more and returns string.
CONCAT_WSThis function concatenates two or more SQL Server string using a separator.
DIFFERENCEReturn the difference between the SOUNDEX values of the specified character expressions
FORMATFormat the expression with the specified format.
LENTo find the length of a specified expression
LEFTReturns the leftmost characters from the specified expression
LTRIMIt removes the empty spaces from Left side of a character expression
LOWERIt converts the given text or expression to Lowercase.
NCHARThie SQL String function returns the Unicode character at the specified integer value
QUOTENAMEIt return the Unicode string with the delimiters
REPLACEWe can use this function to replace the existing string with new value.
REPLICATERepeat the existing sentence for a given number of times.
REVERSEHelps to reverse the specified expression
RIGHTReturn the rightmost characters from a given expression
RTRIMIt removes empty spaces from the Right-hand side of a given expression.
PATINDEXIt is used to return the starting index position of the first occurrence of a pattern in an expression.
SOUNDEXThis SQL String function returns the SOUNDEX code.
SPACEReturns the string of repeated spaces.
STRIt returns the string representation of the numeric expression.
STRING_ESCAPEThis function escapes the special characters from the text.
STRING_SPLITSplit the character expression using the separator.
SUBSTRINGIt returns a specified number of characters from the given expression.
TRIMRemove the empty spaces from both the right and left side.
UNICODEReturn the Unicode (integer) value, as defined in Unicode standards.
UPPER This function convert the given text or expression to Uppercase

Comments are closed.