[英]Escape special characters both „ and “ in SQL Server
I have a product name with „ “
characters. 我有一个带
„ “
字符的产品名称。 How can escape both ( „
and “
) characters in SQL Server. 如何在SQL Server中转义两个(
„
和“
)字符。
I have tried the following. 我尝试了以下方法。
SELECT REPLACE('ts. & dot. test testing. „G“ ', '\„\“', '');
You don't need to escape either, just need nested REPLACE()
statements: 您也不需要转义,只需要嵌套的
REPLACE()
语句即可:
SELECT REPLACE(REPLACE('ts. & dot. test testing. „G“ ', '„', ''),'“','');
Returns: ts. & dot. test testing. G
返回:
ts. & dot. test testing. G
ts. & dot. test testing. G
REPLACE()
is looking for a literal string to replace, in your example the literal string „“
never occurs, so nothing is replaced. REPLACE()
正在寻找要替换的文字字符串,在您的示例中,文字字符串„“
从未出现,因此没有任何替换。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.