Posted on Leave a comment

super trim

CREATE FUNCTION dbo.trim( @val nvarchar(max) )
RETURNS nvarchar(max)
   DECLARE @tab nchar(1)
         , @lf nchar(1)
         , @cr nchar(1)
         , @crlf nchar(2)

   SET @tab = char(9)
   SET @lf = char(10)
   SET @cr = char(13)
   SET @crlf = char(13) + char(10)

   RETURN ( replace(replace(replace(replace(ltrim(rtrim(@val)), @tab, ”), @crlf, ”), @lf, ”), @cr, ” ) )

END  –trim()

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.