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