One of my friends who love to work at ORACLE, ask me that the Function TRIM() is supported by any version of SQL Server.
Like ORACLE the SQL server does not have function which can trim leading or trailing spaces of any string at the same time.
We can use LTRIM() and RTRIM() function together to get the output like TRIM() function in SQL Server.
SELECT LTRIM(RTRIM(‘ Hello ‘)) As Result
However we can create an UDF function named TRIM to get the same functionality like ORCALE TRIM() Function.
IF OBJECT_ID (N’dbo.TRIM ‘) IS NOT NULL
DROP FUNCTION dbo.TRIM
CREATE FUNCTION dbo.TRIM
SELECT dbo.TRIM(‘ Hello ‘) As Result
Hope you like it.
Posted by: MR. JOYDEEP DAS