January 22, 2008 at 2:43 am
Hi
I am having trouble removing trailing spaces in a table column (query phrase).
so far i have tried using Ltrim , rtrim but no luck , i have used len and substring as well . funny thing is when using len(queryphrase) its counting the trailing space.
also an update with replace dosen't work
I have set the table with ansi padding off and have used both nvarchar and char columns to see if it made any difference , but no luck there either.
Are there any other options available ???
Thanks in advance
🙂
January 22, 2008 at 2:53 am
Check the following link may be useful
January 22, 2008 at 2:56 am
LEN() function is NOT counting trailing spaces.
DATALENGTH() does.
Are you the spaces really are spaces (ascii value 32)?
Make sure they are not hard-spaces (ascii value 160).
N 56°04'39.16"
E 12°55'05.25"
January 22, 2008 at 4:20 am
June 14, 2011 at 9:44 am
Can you advise as to how you fixed the issue and how you knew it was a CR/LF. We are having the same issue when loading mainframe data into our systems and an RTRIM is not working. Thanks.
June 14, 2011 at 10:05 am
SELECT ASCII(SUBSTRING(Col1, n, 1))
N 56°04'39.16"
E 12°55'05.25"
October 3, 2012 at 12:49 pm
I used following to remove only trailing white spaces in a CHAR(30) column:
RTRIM(LTRIM(CAST(City_Id As VARCHAR(30)))) AS City_Id
Piyush Varma
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply