开发者

Replacing Chars in Different Encoding

开发者 https://www.devze.com 2023-02-22 02:01 出处:网络
I imported data into a table from a backup I was given. Now I realized that this backup was made from a database with another collation and thus I have invalid characters, such as ├í instead of á.

I imported data into a table from a backup I was given. Now I realized that this backup was made from a database with another collation and thus I have invalid characters, such as ├í instead of á.

How can I replace such characters?

I tried this, but doesn't work:

UPDATE Table1
SET Field1 = REPLACE(Field1, '├í', 'á')

Also note that I don't see: ├í, but I see the í preceded by an em开发者_高级运维pty square.


Where is it that you “don’t see ├í, but [you] see the í preceded by an empty square”?

What’s the data type of Table1.Field1? What is the contents in binary of some rows of Field1 that need to be changed? What is the collation of Field1, which you can find with

SELECT SQL_VARIANT_PROPERTY(Field1,'Collation') FROM Table1;

It might be as simple as changing your UPDATE statement to specify its contents in Unicode:

UPDATE Table1 SET
  Field1 = REPLACE(Field1, N'├í', N'á')

Or it might not be. If not, it would help if you posted what you get when you SELECT CAST(Field1 AS VARBINARY(40)) -- or whatever length gives the full Field1 contents. You might need to apply a collation specification in the REPLACE expression.

0

精彩评论

暂无评论...
验证码 换一张
取 消