RTRIM (Azure Cosmos DB)

APPLIES TO: SQL API

Returns a string expression after it removes trailing whitespace or specified characters.

Syntax

RTRIM(<str_expr1>[, <str_expr2>])  

Arguments

str_expr1
Is a string expression

str_expr2
Is an optional string expression to be trimmed from str_expr1. If not set, the default is whitespace.

Return types

Returns a string expression.

Examples

The following example shows how to use RTRIM inside a query.

SELECT RTRIM("   abc") AS t1, 
RTRIM("   abc   ") AS t2, 
RTRIM("abc   ") AS t3, 
RTRIM("abc") AS t4,
RTRIM("abc", "bc") AS t5,
RTRIM("abc", "abc") AS t6

Here is the result set.

[
    {
        "t1": "   abc",
        "t2": "   abc",
        "t3": "abc",
        "t4": "abc",
        "t5": "a",
        "t6": ""
    }
]

Remarks

This system function will not utilize the index.

Next steps