Posted By

emregulcan on 12/11/10


Tagged

sql trim LTrim RTrim


Versions (?)

SQL Trim Function


 / Published in: SQL
 

Today I need Trim() function in sql, but in Sql 2005 there is no function. Because of that I wrote this user (scalar) fuction. It's very basic; -First; it's Right Trim (RTrim()) string - And then Left Trim (LTrim())

  1. CREATE FUNCTION dbo.Trim
  2. (
  3. @string nvarchar(max)
  4. )
  5. RETURNS nvarchar(max)
  6. AS
  7. BEGIN
  8. RETURN LTRIM(RTRIM(@string))
  9. END

Report this snippet  

You need to login to post a comment.