Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get rid of double quote from column's value?

Here is the table, each column value is wrapped with double quotes (").

Name    Number      Address Phone1  Fax Value   Status
"Test"  "10000000"  "AB"    "5555"  "555"   "555"   "Active" 

How to remove double quote from each column? I tried this for each column:-

UPDATE Table 
SET Name = substring(Name,1,len(Name)-1) 
where substring(Name,len(Name),1) = '"'

but looking for more reliable solution. This fails if any column has trailing white space

like image 208
User13839404 Avatar asked Feb 21 '12 15:02

User13839404


2 Answers

Just use REPLACE?

...
SET Name = REPLACE(Name,'"', '')
...
like image 134
gbn Avatar answered Oct 21 '22 11:10

gbn


UPDATE Table
    SET Name = REPLACE(Name, '"', '')
    WHERE CHARINDEX('"', Name) <> 0
like image 45
Joe Stefanelli Avatar answered Oct 21 '22 10:10

Joe Stefanelli