MS SQL Server String Related Functions
July 1, 2020
Sometimes you may need to process some strings to get your desired result. There are some built-in string related functions in MS SQL Server which helps you to do your desired string related operation. Here are some very popular and useful built-in string related functions in MS SQL Server:
| Function_Name | Description |
|---|---|
| ASCII | Return the ASCII code value of the leftmost character of a character expression. |
| CHAR | Convert an ASCII integer value to a character. |
| CHARINDEX | Search for a substring inside a string starting from a specified location and return the position of the substring |
| CONCAT | Join two or more strings into one string. |
| CONCAT_WS | Concatenate multiple strings with a separator into a single string. |
| DIFFERENCE | Compare the SOUNDEX() values of two strings. |
| FORMAT | Return a value formatted with the specified format and optional culture. |
| LEFT | Extract a given a number of characters from a character string starting from the left. |
| LEN | Returns the number of characters of the specified string expression. |
| LOWER | Convert a string to lowercase. |
| LTRIM | Returns a character expression after removing it’s leading blanks. |
| NCHAR | Return the Unicode character with the specified integer code, as defined by the Unicode standard. |
| PATINDEX | Returns the starting position of the first occurrence of a pattern in a string |
| QUOTENAME | Returns a Unicode string with the delimiters added to make the input string a valid delimited identifier |
| REPLACE | Replace all occurrences of a substring, within a string, with another substring |
| REPLICATE | Return a string repeated a specified number of times |
| REVERSE | Return the reverse order of a character string |
| RIGHT | Extract a given a number of characters from a character string starting from the right |
| RTRIM | Returns a character expression after removing it’s trailing blanks |
| SOUNDEX | Return a four-character (SOUNDEX) code of a string based on how it is spoken |
| SPACE | Returns a string of repeated spaces |
| STR | Returns character data converted from numeric data |
| STRING_AGG | Concatenate rows of strings with a specified separator into a new string |
| STRING_ESCAPE | Escapes special characters in a string and returns a new string with escaped characters |
| STRING_SPLIT | A table-valued function that splits a string into rows of substrings based on a specified separator |
| STUFF | Delete a part of a string and then insert another substring into the string starting at a specified position |
| SUBSTRING | Extract a substring within a string starting from a specified location with a specified length |
| TRANSLATE | Replace several single-characters, one-to-one translation in one operation |
| TRIM | Return a new string from a specified string after removing all leading and trailing blanks |
| UNICODE | Returns the integer value, as defined by the Unicode standard, of a character |
| UPPER | Convert a string to uppercase |
In this tutorial, I have shown you different string related built-in functions in MS SQL Server. Hope you have enjoyed the tutorial. If you want to get updated, like my facebook page http://www.facebook.com/freetechtrainer and stay connected.