如何使用tsql中的替换函数更新字符串的一部分? [英] How to update a part of the string using replace function in tsql?
本文介绍了如何使用tsql中的替换函数更新字符串的一部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨我有一列 nvarchar(1000) 类型.我需要从该列中删除编码字符并将它们替换为它们的特殊字符.例如:
Hi I have a column of nvarchar(1000) type. I need to get rid of encode characters from that column and replace them with their special characters. For Example:
column value is : 'This text values contains this '&' this'.
我必须将 '&'
替换为 '&'.
I have to replace '&'
with '&'.
- 首先必须在列中找到具有
'&'
的记录(可能正在使用类似条件) - 然后只用它的特殊字符替换这个词
- First have to find the record which has
'&'
in the column (may be using like condition) - And then replace only this word with its special character
我该怎么做?Pl.帮助
How do i do that? Pl. help
推荐答案
这将在整个列中替换
REPLACE(MyColumn, '&', '&')
您必须嵌套其他替代品...
You'll have to nest other replacements...
REPLACE(REPLACE(MyColumn, '&', '&'), '>', '>')
一起
UPDATE myTable
SET MyColumn = REPLACE(MyColumn, '&', '&')
WHERE MyColumn LIKE '%&%'
这篇关于如何使用tsql中的替换函数更新字符串的一部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文