简体   繁体   中英

Escape special characters both „ and “ in SQL Server

I have a product name with „ “ characters. How can escape both ( and ) characters in 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:

SELECT REPLACE(REPLACE('ts. & dot. test testing. „G“ ', '„', ''),'“','');

Returns: 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM