Trim Function
The Trim() removes all blank spaces or specified characters from the right-hand side and left-hand side of a string, i.e. start and end, the function requires minimum of one (1) argument and maximum 2. Comparison is case sensitive
If only one parameter is provided blank spaces are removed from both sides of string. Syntax for Trim() is Trim( String , [ string to remove ] ) .
The [ string to remove ] is optional and specified string will be removed from the sides of string.
SELECT TRIM(' SQLDatabase.Net ') /* returns SQLDatabase.Net */ ;
SELECT TRIM('SQLDatabase.Net', '.Net') /* returns SQLDatabase */ ;
SELECT TRIM('SQLDatabase.Net', 'SQL') /* returns Database.Net */ ;
SELECT TRIM('SQLDatabase.Net.Net.Net.Net', '.Net') /* returns SQLDatabase all ".Net" are trimed */ ;
SELECT TRIM('SQLSQLSQLSQLDatabase.Net.Net.Net.Net', '.Net') /* returns SQLSQLSQLSQLDatabase all ".Net" are trimed */ ;
SELECT TRIM('SQLSQLSQLSQLDatabase.Net.Net.Net.Net', 'SQL') /* returns Database.Net.Net.Net.Net all "SQL" are trimed */ ;
SELECT TRIM('SQLSQLSqlDatabase.Net runs SQLSQL', 'SQL') /* returns "SqlDatabase.Net runs " */ ;
SELECT TRIM('$$$ dollar is a symbol written as $$$$$$$$$', '$') /* returns " dollar is a symbol written as " */ ;
Trim function is widely used to correct user input and to trim unwanted extra spaces or words.