Great! But what if you want to remove a set of characters from the beginning and end of a string? You can also use
TRIM() to do that. This requires an additional argument: a string containing the characters you want to remove (the first argument) and the actual text (the second argument).
Let's remove the following characters from a sentence:
SELECT TRIM(N' !?.' FROM N'?What is the best way to do it? !.');
Notice that this function contains a
FROM between the list of characters to remove and the text.
This is the result you obtain:
N'What is the best way to do it'
As you can see, all specified characters were removed from the beginning and end of the text.