lambypie
lambypie

Reputation: 481

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“ ', '\„\“', '');

Upvotes: 1

Views: 61

Answers (1)

Hart CO
Hart CO

Reputation: 34774

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

REPLACE() is looking for a literal string to replace, in your example the literal string „“ never occurs, so nothing is replaced.

Upvotes: 2

Related Questions