SQL to replace smart quotes

Does anyone know an SQL command to replace MS Office smart quotes with their ASCII cousins? I am using an oracle database and the fields are of type varchar2

+4
source share
5 answers

table update table set column = replace (replace (column, chr (147), '' '), chr (148),' '')

+3
source
REPLACE(REPLACE(str, '`', ''''), 'ยด', '''') 

Or am I missing your question?

+2
source

I had a similar problem. For me, after the quotes were stored in the database, they appeared, thus, โ€œร‚โ€.

 SELECT abstract FROM foo WHERE version = '1.0' and newscode = 'au20309'; 

Maeร‚r ffordd gynaliadwy y mae bwyd yn cael ei dyfu, ei brynu aร‚i baratoi ...

This is how I replaced them. First find the ascii value for this unusual โ€œร‚โ€ character.

 SELECT ascii('ร‚') FROM DUAL; -- returns 50050 

Then use the chr function to render "ร‚". || The function combines two characters. The q function is useful for quoting a smart quote string.

 SELECT REPLACE(abstract,chr(50050) || q'#'#' , q'#'#') FROM foo WHERE version = '1.0' and newscode = 'au20309'; 

Mae'r ffordd gynaliadwy y mae bwyd yn cael ei dyfu, ei brynu a'i baratoi ...

This worked perfectly for me on our Oracle 10 system.

+1
source

TRANSLATE would be more suitable than REPLACE.

 TRANSLATE(str, '`ยด', '''''') 

http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/functions204.htm#sthref2477

0
source
 update table set column = replace( column, string_to_replace, [ replacement_string ] ) 
-1
source

All Articles