• You may have leading and/or trailing tabs instead of spaces which the trim's won't replace. You can use CHARINDEX to find CHAR(9) in a string and then use the replace function if that is the issue.

    /****** Script for SelectTopNRows command from SSMS ******/

    DECLARE @REALNAME varchar(255)

    SET @REALNAME = ' Ricki Ricardo'

    select LEN(@realname)

    select len(RTRIM(ltrim(@realname)))

    SET @REALNAME = 'Ricki Ricardo'

    select LEN(@realname)

    select len(RTRIM(ltrim(@realname)))



    Microsoft Certified Master - SQL Server 2008
    Follow me on twitter: @keith_tate

    Forum Etiquette: How to post data/code on a forum to get the best help[/url]