TRIM Function in SQL Server 2017
we can see that most of the languages have the trim function. But, Today I am going to write about Trim Function in SQL Server 2017. Trim Function helps to remove White spaces or other specified characters from the start as well as the end of the String.
TRIM ( [ characters FROM ] string )
Where Characters represents variable, literals or function call of any non-LOB character types (nvarchar, varchar, nchar, or char). But Data type like. varchar(max) and nvarchar(max) are not allowed.
1. Space Character Remove from both side of String
SELECT TRIM( ' TTMIND ') AS Output;
2. Removing specified character from the string
SELECT TRIM( '.,! ' FROM '# TTMIND ! .') AS Output;