Remove Quotation Marks On All Rows in a Column

2019-06-11 10:56发布

问题:

I have a column in a table that has values encapsulated in quotation marks (i.e. "USA", "Mexico", "Russia", "China", etc.) I would like to remove the quotation marks and leave the rest of the string intact (USA, Mexico, etc.). Is there a simple statement for this? Or do I need to use a combination of LEFT, RIGHT, and SUBSTRING functions? Thanks in advance

回答1:

This will remove all the " marks, even those in the middle of the value.

UPDATE YourTable
SET CountryName = REPLACE(CountryName, '"', '');


回答2:

Well, if you want to get rid of all double quotes, how about:

SELECT REPLACE(countryColumn, '"', '') AS countryColumn
FROM   theTable

Or a similar update if you actually want to modify the data.