SQL ABS Function

Example

Return the absolute value of a number:

SELECT Abs(-243.5) AS AbsNum;

Definition and Usage

The ABS() function returns the absolute value of a number.

Syntax

ABS(number)

Continue reading SQL ABS Function

SQL UPPER Function

Example

Convert the text to upper-case:

SELECT UPPER('SQL Tutorial is FUN!');

Definition and Usage

The UPPER() function converts a string to upper-case.

Note: Also look at the LOWER() function.

Syntax

UPPER(text)

Continue reading SQL UPPER Function

SQL UNICODE Function

Example

Return an integer value (the Unicode value), for the first character of the input expression:

SELECT UNICODE('Atlanta');

Definition and Usage

The UNICODE() function returns an integer value (the Unicode value), for the first character of the input expression.

Syntax

UNICODE(character_expression)

Continue reading SQL UNICODE Function

SQL TRIM Function

Example

Remove leading and trailing spaces from a string:

SELECT TRIM('     SQL Tutorial!     ') AS TrimmedString;

Definition and Usage

The TRIM() function removes the space character OR other specified characters from the start or end of a string.

By default, the TRIM() function removes leading and trailing spaces from a string.

Note: Also look at the LTRIM() and RTRIM() functions.

Syntax

TRIM([characters FROM ]string)

Continue reading SQL TRIM Function

SQL TRANSLATE Function

Example

Return the string from the first argument AFTER the characters specified in the second argument are translated into the characters specified in the third argument:

SELECT TRANSLATE('Monday', 'Monday', 'Sunday'); // Results in Sunday

Definition and Usage

The TRANSLATE() function returns the string from the first argument after the characters specified in the second argument are translated into the characters specified in the third argument.

Note: The TRANSLATE() function will return an error if characters and translations have different lengths.

Syntax

TRANSLATE(string, characters, translations)

Continue reading SQL TRANSLATE Function

SQL SUBSTRING Function

Example

Extract 3 characters from a string, starting in position 1:

SELECT SUBSTRING('SQL Tutorial', 1, 3) AS ExtractString;

Definition and Usage

The SUBSTRING() function extracts some characters from a string.

Syntax

SUBSTRING(string, start, length)

Continue reading SQL SUBSTRING Function

SQL STUFF Function

Example

Delete 3 characters from a string, starting in position 1, and then insert “HTML” in position 1:

SELECT STUFF('SQL Tutorial', 1, 3, 'HTML');

Definition and Usage

The STUFF() function deletes a part of a string and then inserts another part into the string, starting at a specified position.

Tip: Also look at the REPLACE() function.

Syntax

STUFF(string, start, length, new_string)

Continue reading SQL STUFF Function

SQL STR Function

Example

Return a number as a string:

SELECT STR(185);

Definition and Usage

The STR() function returns a number as a string.

Syntax

STR(number, length, decimals)

Continue reading SQL STR Function

SQL SPACE Function

Example

Return a string with 10 spaces:

SELECT SPACE(10);

Definition and Usage

The SPACE() function returns a string of the specified number of space characters.

SPACE(number)

Continue reading SQL SPACE Function

SQL SOUNDEX Function

Example

Evaluate the similarity of two strings, and return a four-character code:

SELECT SOUNDEX('Juice'), SOUNDEX('Jucy');

Definition and Usage

The SOUNDEX() function returns a four-character code to evaluate the similarity of two expressions.

Note: The SOUNDEX() converts the string to a four-character code based on how the string sounds when spoken.

Tip: Also look at the DIFFERENCE() function.

Syntax

SOUNDEX(expression)

Continue reading SQL SOUNDEX Function