替换不同编码中的字符
我从提供的备份中将数据导入到表中。现在我意识到这个备份是从具有另一种排序规则的数据库中创建的,因此我有无效字符,例如 ├í
而不是 á
。
我怎样才能替换这些字符?
我尝试了这个,但不起作用:
UPDATE Table1
SET Field1 = REPLACE(Field1, '├í', 'á')
另请注意,我没有看到:├í
,但我看到 í
前面有一个空方块。
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 empty square.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在哪里“看不到 ├í,但[您]看到 í 前面有一个空方块”?
Table1.Field1 的数据类型是什么? Field1中需要改变的部分行的二进制内容是什么? Field1 的排序规则是什么,您可以使用它找到
它可能就像更改 UPDATE 语句以以 Unicode 指定其内容一样简单:
也可能不是。如果没有,如果您发布 SELECT CAST(Field1 AS VARBINARY(40)) 时得到的内容,或者给出完整 Field1 内容的任何长度,将会有所帮助。您可能需要在 REPLACE 表达式中应用排序规则规范。
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
It might be as simple as changing your UPDATE statement to specify its contents in Unicode:
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.