How to trim string using predefined special characters in SQL Server?
问题 I want to trim SQL Server strings using some special characters such as "،,.?!؛,،,><=+ـ". The SQL server ltrim and rtrim functions only strips the space characters. DECLARE @Str NVARCHAR(100) = N',,,,,!؛Computation+Time, Cost،,.?!؛,،,><=+ـ' SELECT dbo.SpecialTrim(@Str, N'،,.?!؛,،,><=+ـ') The result : Computation+Time, Cost Have anyone any ideas in order to implement SpecialTrim function? 回答1: The below hardcodes the pattern. It looks for the first character that is not one of the characters