SQL Server automatically trimming spaces?

  • Hi Friends,

    Does SQL Server/T-SQL automatically trim trailing spaces?  I have a file that I have loaded through the Bulk Copy (bcp) command wherein some of the strings have a trailing space at the very end of them.  I need to keep this space.  However, when I run a query with the "len" length function, it is not counting the space. 

    Also, I have attempted to insert a record with the T-SQL "insert" statement that contained a space character (e.g., INSERT INTO TABLE...VALUES ('ZZZZ ')   )    at the end of it.  But again, when I queried the table, it ignored the space in the "len" command. 

    Is there a reason for this?  I thought one would have to specify the "rtrim" function in order to get rid of spaces rather than have them automatically trimmed.

    Any help would be greatly appreciated.

    p.s. I also posted this question in the T-SQL forum since I didn't know which location would be more appropriate.

    Thanks,

    Zaid

  • Please do not cross-post, we monitor all boards.

    Finish the thread here : http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=224566

  • Sorry about that.

    Thanks

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply