Trim Trailing Whitespace, Tab, Newline, Carriage Returns, etc
The best way would probably be to create a CLR function and use .NET framework libraries.

A TSQL attempt is below.

DECLARE @Pattern NVARCHAR (50) = N'%[^' + 
/*List from http://stackoverflow.com/a/18169122/73226 */
NCHAR(0x0009) +  /*tab*/
NCHAR(0x000A) +  /*line feed*/
NCHAR(0x000B) +  /*line tabulation*/
NCHAR(0x000C) +  /*form feed*/
NCHAR(0x000D) +  /*carriage return*/
/*Various spaces from https://www.cs.tut.fi/~jkorpela/chars/spaces.html */
NCHAR(0x0020) +  
NCHAR(0x00A0) +  
NCHAR(0x1680) +  
NCHAR(0x180E) +  
NCHAR(0x2000) +  
NCHAR(0x2001) +  
NCHAR(0x2002) +  
NCHAR(0x2003) +  
NCHAR(0x2004) +  
NCHAR(0x2005) +  
NCHAR(0x2006) +  
NCHAR(0x2007) +  
NCHAR(0x2008) +  
NCHAR(0x2009) +  
NCHAR(0x200A) +  
NCHAR(0x200B) +  
NCHAR(0x202F) +  
NCHAR(0x205F) +  
NCHAR(0x3000) +  
NCHAR(0xFEFF) +
N']%' COLLATE Latin1_General_100_BIN2;

WITH T(String) AS
(
SELECT '         leading only' union all
SELECT '

Line breaks

' union all
SELECT '    tab and space    ' union all
SELECT '' 
)
SELECT '[' + SUBSTRING(String,Start,len(String + '..') - Start - Finish) + ']'
FROM T
CROSS APPLY
(
SELECT  PATINDEX(@Pattern,String),
        PATINDEX(@Pattern,REVERSE(String))
)ca(Start, Finish)


The [ and ] delimiters are applied just to make it easier to verify there is no white space lurking there. Remove these when you're happy this is the case.