|
SQL >
SQL String Functions
In this section, we cover common string functions seen in SQL. Different RDBMS may employ different string functions, and there may also be differences in the syntax for each RDBMS even when the function call is the same. All such differences are explained in each section. Please note that we do not list all possible SQL string functions in this tutorial. Rather, the most commonly used ones are covered.
Key Takeaway: SQL string functions let you transform, search, and extract data from text columns. While the most important ones — like SUBSTRING, TRIM, and LENGTH — are widely available, exact syntax may differ between MySQL, Oracle, SQL Server, and PostgreSQL.
| SQL String Function | Description |
| CAST | Converts data from one data type to another. |
| CONVERT | Converts data from one data type to another. |
| CONCATENATE | Combines the results of several columns together. |
| SUBSTRING | Returns a portion of a string. |
| INSTR | Finds the starting location of a pattern in a string. |
| TRIM | Removes specified prefix or suffix from a string. The most common pattern being removed is white space. |
| LENGTH | Returns the length of a string. |
| REPLACE | Updates the content of a string. |
| TO_DATE | Converts a string to a date. |
Frequently Asked Questions
- What are SQL string functions?
- SQL string functions are built-in functions used to manipulate and transform text (string) values in queries. Common examples include SUBSTRING, TRIM, LENGTH, REPLACE, CAST, CONVERT, INSTR, CONCATENATE, and TO_DATE.
- Are SQL string functions the same in all databases?
- The core functionality is similar, but function names and syntax can vary across RDBMS platforms. For example, string concatenation uses CONCAT() in MySQL, || in Oracle/PostgreSQL, and + in SQL Server.
- Which SQL function extracts part of a string?
- The SUBSTRING function (also called SUBSTR in Oracle) extracts a portion of a string, given a starting position and optional length.
- How do you convert a string to a date in SQL?
- In Oracle, use TO_DATE(string, format). In SQL Server use CONVERT or CAST. In MySQL use STR_TO_DATE(string, format). Each database has slightly different syntax for date conversion.
This page was last updated on March 19, 2026.
Copyright © 2026 1keydata.com All Rights Reserved
Privacy Policy About Contact |