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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Manual Data Entered - REPLACE command help

Author  Topic 

indrajit_wsr
Starting Member

2 Posts

Posted - 2012-10-08 : 06:11:08
Hello,
We have an SQL server system where in we have a data that seems to be manually entered and have got a weird character at its end not sure if its carriage return or tab as below

J->
where -> is that junk character I m seeing in data

select REPLACE(REPLACE('J->', CHAR(10), ''), CHAR(13), '')

I need to replace this -> with spaces. The data type of this field is char(10) and for this particular record it appears to be on 2nd character.

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-10-08 : 06:59:37
If you do want to replace the CHAR(10) and char(13) with spaces or blanks, what you are doing is correct. But I suspect the characters are something other than those two. You can find what those are using
SELECT CAST('J->' AS VARBINARY)
When I do that with the string you posted, I get this:
0x4A2D3E1A
Now, you can replace any of the four characters that you want to - for example, to replace the second character:
REPLACE('J->',CHAR(0x2D),'')
Go to Top of Page

indrajit_wsr
Starting Member

2 Posts

Posted - 2012-10-08 : 08:05:45
Thank You..!!!
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-10-08 : 08:21:47
Glad to help!
Go to Top of Page
   

- Advertisement -