SQL ASIN Function

Example

Return the arc sine of a number:

SELECT ASIN(0.25);

Definition and Usage

The ASIN() function returns the arc sine of a number.

The specified number must be between -1 to 1, otherwise this function returns NULL.

Syntax

ASIN(number)

Continue reading SQL ASIN Function

SQL ACOS Function

Example

Return the arc cosine of a number:

SELECT ACOS(0.25);

Definition and Usage

The ACOS() function returns the arc cosine of a number.

The specified number must be between -1 to 1, otherwise this function returns NULL.

Syntax

ACOS(number)

Continue reading SQL ACOS Function

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