SQL Functions Library
Explore our SQL Functions Library for a comprehensive list of SQL functions with examples, syntax, and usage tips to enhance your queries.
Explore our SQL Functions Library for a comprehensive list of SQL functions with examples, syntax, and usage tips to enhance your queries.
Explore our SQL Functions Library for a comprehensive list of SQL functions with examples, syntax, and usage tips to enhance your queries.
String Functions
Numeric Functions
Date Functions
Window Functions
String Functions
Rounds a number to a specified number of decimal places or to the nearest integer.
ROUND(number [, decimals])
Deletes a specified length of characters and inserts another string at a specified start position in a string.
STUFF(original_string, start_position, length, insert_string)
Returns the starting position of the first occurrence of a pattern in a string. Uses pattern matching with wildcards.
PATINDEX('%pattern%', string)
Returns the starting position of a substring within a string. Position is 1-based (first character is position 1).
CHARINDEX(substring, string [, start_position])
-- Some DBMS use POSITION() or INSTR() instead
Extracts a specified number of characters from the end (right side) of a string.
RIGHT(string, number_of_characters)
Extracts a specified number of characters from the beginning (left side) of a string.
LEFT(string, number_of_characters)
Replaces all occurrences of a substring within a string with another substring.
REPLACE(original_string, search_string, replacement_string)
Returns the number of characters in a string. Note: Function name varies by DBMS (LENGTH in most, LEN in SQL Server).
LENGTH(string) -- Most databases
LEN(string) -- SQL Server
Removes leading and/or trailing spaces (or specified characters) from a string.
TRIM([{LEADING | TRAILING | BOTH}] [removal_string] FROM string)
-- or simple form
TRIM(string)
String Functions
Rounds a number to a specified number of decimal places or to the nearest integer.
ROUND(number [, decimals])
Deletes a specified length of characters and inserts another string at a specified start position in a string.
STUFF(original_string, start_position, length, insert_string)
Returns the starting position of the first occurrence of a pattern in a string. Uses pattern matching with wildcards.
PATINDEX('%pattern%', string)
Returns the starting position of a substring within a string. Position is 1-based (first character is position 1).
CHARINDEX(substring, string [, start_position])
-- Some DBMS use POSITION() or INSTR() instead
Extracts a specified number of characters from the end (right side) of a string.
RIGHT(string, number_of_characters)
Extracts a specified number of characters from the beginning (left side) of a string.
LEFT(string, number_of_characters)
Replaces all occurrences of a substring within a string with another substring.
REPLACE(original_string, search_string, replacement_string)
Returns the number of characters in a string. Note: Function name varies by DBMS (LENGTH in most, LEN in SQL Server).
LENGTH(string) -- Most databases
LEN(string) -- SQL Server
Removes leading and/or trailing spaces (or specified characters) from a string.
TRIM([{LEADING | TRAILING | BOTH}] [removal_string] FROM string)
-- or simple form
TRIM(string)
String Functions
Rounds a number to a specified number of decimal places or to the nearest integer.
ROUND(number [, decimals])
Deletes a specified length of characters and inserts another string at a specified start position in a string.
STUFF(original_string, start_position, length, insert_string)
Returns the starting position of the first occurrence of a pattern in a string. Uses pattern matching with wildcards.
PATINDEX('%pattern%', string)
Returns the starting position of a substring within a string. Position is 1-based (first character is position 1).
CHARINDEX(substring, string [, start_position])
-- Some DBMS use POSITION() or INSTR() instead
Extracts a specified number of characters from the end (right side) of a string.
RIGHT(string, number_of_characters)
Extracts a specified number of characters from the beginning (left side) of a string.
LEFT(string, number_of_characters)
Replaces all occurrences of a substring within a string with another substring.
REPLACE(original_string, search_string, replacement_string)
Returns the number of characters in a string. Note: Function name varies by DBMS (LENGTH in most, LEN in SQL Server).
LENGTH(string) -- Most databases
LEN(string) -- SQL Server
Removes leading and/or trailing spaces (or specified characters) from a string.
TRIM([{LEADING | TRAILING | BOTH}] [removal_string] FROM string)
-- or simple form
TRIM(string)
Numeric Functions
Numeric Functions
Numeric Functions
Date Functions
Date Functions
Date Functions
Window Functions
Window Functions
Window Functions
Double Click to Update Anything
Double click the image placeholders to add images. Do the same for any text, then tweak styles and publish.
Get Started
Learn More