SQL Server 2008 : replace string(SQL Server 2008:替换字符串)
问题描述
我有一个表格,其中一列的多行中有一个错误符号(' ').
I have a table with an erroneous symbol('�') in a number of rows in one column.
下面的 TSQL 脚本不起作用.
The TSQL script below does not work.
UPDATE S
SET S.Offering_Details = REPLACE(S.Offering_Details, '�', '...')
FROM tblSacrifices S
相关列的数据类型为 nvarchar(230) 并允许空条目.
The column in question has datatype of nvarchar(230) and allows null entries.
数据来自通过 Visual Studio Windows 应用程序从 Excel 和 d 转换而来的 csv 文件.数据最初是...",但我认为 word/excel 可能将其归类为一个字符(而不是 3 个单独的.").当我的应用程序从 CSV 文件读取原始字符串时,它(无意中)在将数据提交到数据库之前将..."替换为"".
The data came from a csv file converted from Excel an d via a Visual studio windows app. The data originally was '...' but I think perhaps word/excel classed this as one character (rather than 3 separate '.'). When my application read the original string from CSV file it (unintentionally) replaced the '...' with '�' before submitting the data into the database.
请帮忙
推荐答案
想通了.感谢大家的帮助.
Figured it out. Thanks all for your help.
我不得不转换为二进制.65500 以上的所有 unicode 字符都需要这样做,因为正常的 REPLACE() 不起作用.
I had to convert to binary. All unicode characters above 65500 require this as normal REPLACE() doesn't work.
UPDATE S
SET S.Offering_Details = REPLACE(S.Offering_Details, nchar(65533) COLLATE Latin1_General_BIN, '...')
FROM tblSacrifices S
这篇关于SQL Server 2008:替换字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:SQL Server 2008:替换字符串
- SQL 临时表问题 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 更改自动增量起始编号? 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
