Nanu
Nanu

Reputation: 3070

SQL Remove Unicode characters

Input :

“This is an example”. “Test Method”

Desired Output:

This is an example. Test Method

I tried using replace method to find and replace these characters but still not able to strip them out. Learnt that both , are Unicode characters and are different from standard quotes i.e. ".

Select
REPLACE(REPLACE(some_text, '“',''),'”','') as DerivedText
from Table

Upvotes: 0

Views: 2744

Answers (1)

IVNSTN
IVNSTN

Reputation: 9299

Both work fine (although only second is correct for unicode):

--1
DECLARE @s VARCHAR(1000) = '“This is an example”. “Test Method”'

PRINT REPLACE(REPLACE(@s, '“', ''), '”', '')
GO
--2
DECLARE @s NVARCHAR(1000) = N'“This is an example”. “Test Method”'

PRINT REPLACE(REPLACE(@s, N'“', N''), N'”', N'')
GO

This is an example. Test Method

This is an example. Test Method

Examine your data.

Upvotes: 3

Related Questions