Showing posts with label varcharselect. Show all posts
Showing posts with label varcharselect. Show all posts

Friday, March 23, 2012

replace special character

I'm trying to remove the special character from a varchar
select replace(my_col,'',' ')
this works, but the problem is that it also seems to replace the 'normal' y
(Database is case sensitive)
Why is that?I'm guessing a bit here, since I don't have that much experience outside of the default collation for SQL. I think your collation is probably Case Sensitive, Accent Insensitive (CS_AI) (see SQL Collation Name in BOL). I think what you will have to do is perform a binary comparison of your search string to ensure that you are only replacing the desired character. You will probably have to perform the comparison in the WHERE clause, since I don't see a binary option for the REPLACE function.

Sorry, that's not much to go on; I hope it might lead you in the right direction.

Regards,

hmscott|||Try this:

select replace(my_col,char(255),'')|||the char(255) has the same effect,
but changing the collation to AS does the trick

Thanks for the replies