SQL String Functions
SQL provides us with a number of tools that give us the ability to manipulate string values. This section of the site gives details of the various functions available and demonstrates real world examples of their use.
The syntax of the string functions can vary for different database systems. For example both Oracle and SQL Server have a string function that can extract a specified section of a string. In Oracle and Microsoft Access this function is called SUBSTR, in SQL Server it is called SUBSTRING. These pages give details of the differing naming conventions / syntax for the different databases of SQL Server, Oracle, Microsoft Access and MySQL.
For a more detailed article on each of the string functions please click the Function names below.
Many string functions are used in combination with other string functions to achieve a desired solution to a problem.
SQL String Functions
-
SQL ASCII string function - how and when to use it with examples
Learn how to use the SQL ASCII string function in your database code to return the numeric ASCII code for a character string. Get up to speed quickly with real-world examples of using this function.
-
Learn what the SQL CHAR function does and see examples of how to use it
Learn how the SQL CHAR function receives a numeric ASCII code and returns the equivalent character such as a letter, punctuation mark or digit.
-
SQL CONCATENATE (appending strings to one another)
SQL allows us to concatenate strings but the syntax varies according to which database system you are using. Concatenation can be used to join strings from different sources...
-
SQL Coalesce function - learn how to use it with examples
The SQL Coalesce function returns the value of the first of its input parameters that is not NULL. Although it can be used with strings, COALESCE it is not limited to being passed just strings.
-
SQL Replace Function, purpose, syntax and common uses
The article explains the functionality, syntax and common uses of the SQL Replace function. The SQL Replace function enables us to look for a certain character phrase in a string and replace it with another character phrase.
-
SQL TRIM Functions, purpose, syntax and common uses
This article demonstrates how to remove white spaces from the beginning and end of string variables using SQL TRIM / LTRIM / RTRIM functions.
-
SQL Substring Function
The SQL Substring function enables us to extract a section of a string. The syntax of this function (and even its name) varies depending on which database you are using.
-
What is STUFF in SQL?
Learn how the SQL Server STUFF function enables you to delete some characters from a string and then insert (or 'stuff') some new characters into the string at the same position as the removed characters.