SQL String Functions

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

A string in Sql is a group of charters stored in Varchar or Nvarchar data type, which is useful to store names, product descriptions, etc. SQL Server String functions enable you to manipulate the string data by searching for the given string and replacing it or adding so on. This article shows you the available list of SQL Server 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 SQL string function.

SQL String FunctionsDescription
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 two or more strings 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
LOWER

This SQL Server string function converts the given text or expression to Lowercase

NCHARIt 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 string value.
REPLICATERepeat the existing string 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 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 of a string expression.
UNICODEReturn the Unicode (integer) value, as defined in Unicode standards.
UPPER This function convert the given text or expression to Uppercase

Comments are closed.