65.9K
CodeProject is changing. Read more.
Home

LTRIM RTRIM doesn’t always work

starIconstarIconstarIconemptyStarIconemptyStarIcon

3.00/5 (1 vote)

Feb 16, 2012

CPOL
viewsIcon

13330

In SQL Server 2008, I do that with a CLR User Defined Function:namespace PIEBALD.Lib{ public static partial class LibSql { public static string Trim ( string Victim ) { return ( Victim.Trim() ) ; } }}Needs to be built into a...

In SQL Server 2008, I do that with a CLR User Defined Function:
namespace PIEBALD.Lib
{
  public static partial class LibSql
  {
    public static string
    Trim
    (
      string Victim
    )
    {
      return ( Victim.Trim() ) ;
    }
  }
}
Needs to be built into a strongly-named Assembly and added to the GAC.
CREATE ASSEMBLY Library FROM 'C:\bin\Library.Sql.dll'
GO

CREATE FUNCTION dbo.Trim(@Victim NVARCHAR(MAX)) RETURNS NVARCHAR(MAX)
AS EXTERNAL NAME Library.[PIEBALD.Lib.LibSql].Trim;
GO