Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Unable to delete space\Special char from Varchar

Author  Topic 

deepugun
Starting Member

11 Posts

Posted - 2013-07-01 : 16:06:59
Hello All,
I have few rows in the address table with spaces(Leading\trail) which is being interpreted as special characters by the application. I have tried to delete those spaces using the below statement but had no success
UPDATE Addr
SET ADDRESS1=Ltrim(rtrim(Address1))
Also if possible please let me know why the extra space is interpreted as '-' in sql server management studio.
Thanks,


James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-07-01 : 16:45:47
That update should work if in fact the leading/trailing characters were spaces. So that means they are something else - some other non-printable characters. There is no one easy way to remove such non-printable characters. See here for example. http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=98382

You can also cast the column to varbinary to see what the characters actually are:
select cast(Address1 as varbinary) from Addr
Go to Top of Page
   

- Advertisement -