The SQL Server provides various String Functions. These functions allow us to alter the individual characters in a string, compare two, search for a substring, extract substrings, and copy. You can also use these SQL String Functions to convert them to lowercase or uppercase.
A string is a group of charters stored in the Varchar or Nvarchar data type, which is useful to store names, product descriptions, etc. The SQL 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 string functions and their definitions.
SQL String Functions
The following table will show you the list of available SQL Server String Functions. Use those links to see the practical example for each one of the string functions.
SQL String Functions | Description |
---|---|
ASCII | It returns the ASCII code of the leftmost character of a character expression. |
CHAR | Convert the integer value (ASCII code) to a character |
CHARINDEX | It returns the index position of a specified expression |
CONCAT | Combine or concatenate two or more and return the string. |
CONCAT_WS | This string function concatenates two or more SQL Server words using a separator. |
DIFFERENCE | Return the difference between the SOUNDEX values of the specified character expressions |
FORMAT | Format the expression in the specified format. |
LEN | To find the length of a specified expression |
LEFT | Returns the leftmost characters from the specified expression |
LTRIM | It removes the empty spaces from the Left side of a character’s expression |
LOWER | It converts the given text or expression to Lowercase. |
NCHAR | It returns the Unicode character at the specified integer value |
QUOTENAME | It returns the Unicode with the delimiters |
REPLACE | We can use this SQL Server function to replace the existing string with a new value. |
REPLICATE | Repeat the existing sentence a given number of times. |
REVERSE | It helps to reverse the specified expression |
RIGHT | Return the rightmost characters from a given expression |
RTRIM | It removes empty spaces from the Right-hand side of a given expression. |
PATINDEX | It is used to return the starting index position of the first occurrence of a pattern in an expression. |
SOUNDEX | This SQL String function returns the SOUNDEX code. |
SPACE | Returns the string of repeated spaces. |
STR | It returns the string representation of the numeric expression. |
STRING_ESCAPE | It escapes the special characters from the text. |
STRING_SPLIT | Split the character expression using the separator. |
STRING_AGG | It concatenates the string expressions and places a specified separator in between them. |
STUFF | Insert one string inside another string |
SUBSTRING | It returns a specified number of characters from the given expression. |
TRANSLATE | It translates the string expression by replacing the specified characters with a new set of characters. |
TRIM | Remove the empty spaces from both the right and left sides. |
UNICODE | Return the Unicode (integer) value, as defined in Unicode standards. |
UPPER | This SQL string function converts the given text or expression to Uppercase. |