Function To trim Leading and trailing characters from string in sql server
This is Scalar Function To trim Leading and trailing characters from string in SQL Server. As there is no in built function in sql server for the same. Using this one can trim leading/trailing any character(s) from string .
As there is no In-built function in sql server to trim leading characters or trailing characters or both from a string in SQL server. This scalar function will help in doing the same.It takes two parameters:
Code-example:Following code-snippet defined it.
Output will be: Select dbo.fn_RemoveLeadingTrailingChar(',1,2,3,4,5,,,',',')
It will trim n number of occurrences of the characters that you want to trim in beginning or end of the string.It is well tested . Passing the null or empty string does not throw any error.
1,2,3,4,5