替换 SQL 2000 中的特殊字符
如何替换数据文件中的特殊字符(特殊字符,如项目符号、百分号、连字符等)?
谢谢
how can I replace special characters in my data files (special characters such as bullet points, percent sign, hyphen etc) ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 T-SQL REPLACE:
对于多个替换,您可以使用级联 REPLACE 语句。
虽然对要点没有任何线索 - 但您应该能够替换任何内容,为该特定字符寻找正确的转义序列。
You can use T-SQL REPLACE:
For more than one substitution you could use cascading REPLACE statements.
No clue though about bullet points - but you should be able to replace anything looking for the right escape sequence for that particular character.
这是一个较晚的答案,但当替换涉及大量令牌和/或它们的管理必须在脚本之外(即从 UI)处理时,它可能会有所帮助。此外,不建议将数据(搜索/替换标记是硬编码的)与逻辑混合。
由于聚合替换不起作用(
UPDATE
执行单个扫描记录),我使用了一个函数来实际执行每个字符串的聚合更新)。我预计性能会比经典解决方案低,但它具有上述优点:This is a late answer, but it might be helpful when replacements involve a large number of tokens and/or their management must dealt outside of the script (i.e. from an UI). Also, mixing data (search/replacement tokens are hardcoded) with logic is not recommended.
Since aggregate replacements do not work (
UPDATE
does a single scan through the records), I have used a function to actually perform the aggregate updates for each string). I expect a lower performance than the classic solution, but it has the advantages mentioned above: