locked
Removing Double Quotes from column values RRS feed

  • Question

  • Hi All,

    I have a table Customers. in thich i have a column 'status' .

    The colum status have values as below.

    "A"

    "A"

    "A"

    "U"

    "U"

    I want to update this whole column and remove the double quotes from the values. there is like 4 million rows.

    can someone please let me know the SQL i can use to accomplish this.

    Thanks in Advance.

    Regards

    Thursday, July 31, 2014 7:06 PM

Answers

  • DECLARE @bloodyDoubleQuotes TABLE (status CHAR(3))
    INSERT INTO @bloodyDoubleQuotes (status)
    VALUES  
    ('"A"'),('"B"'),('"C"'),('"D"'),('"E"'),('"F"'),('"G"')
    
    UPDATE @bloodyDoubleQuotes
    SET status = REPLACE(status,'"','')
    
    SELECT * FROM @bloodyDoubleQuotes

    Boom boom, pow!
    • Proposed as answer by Prashanth Jayaram Thursday, July 31, 2014 7:28 PM
    • Marked as answer by SA260884 Thursday, July 31, 2014 7:42 PM
    Thursday, July 31, 2014 7:13 PM

All replies

  • DECLARE @bloodyDoubleQuotes TABLE (status CHAR(3))
    INSERT INTO @bloodyDoubleQuotes (status)
    VALUES  
    ('"A"'),('"B"'),('"C"'),('"D"'),('"E"'),('"F"'),('"G"')
    
    UPDATE @bloodyDoubleQuotes
    SET status = REPLACE(status,'"','')
    
    SELECT * FROM @bloodyDoubleQuotes

    Boom boom, pow!
    • Proposed as answer by Prashanth Jayaram Thursday, July 31, 2014 7:28 PM
    • Marked as answer by SA260884 Thursday, July 31, 2014 7:42 PM
    Thursday, July 31, 2014 7:13 PM
  • Can you try the below code?

    UPDATE tableA
    SET status = REPLACE(status,'"','')
    where status like '%"%'
    --Prashanth

    • Proposed as answer by ABCD0008 Thursday, July 31, 2014 10:13 PM
    • Unproposed as answer by ABCD0008 Thursday, July 31, 2014 10:13 PM
    Thursday, July 31, 2014 7:28 PM