How to TRIM a string in MSSQL

To TRIM a string in MSSQL you can use the following Userdefinedfunction Snippet.

Sample MSSQL

CREATE FUNCTION dbo.TRIM(@inputString VARCHAR(MAX))
RETURNS VARCHAR(MAX)
BEGIN
RETURN LTRIM(RTRIM(@inputString))
END

Please rate this snippet