locked
Replace ' with nothing RRS feed

  • Question

  • I want to replace the following words like this,

    OldWord     NewWord

    -----------------------------

    Children's      Childrens

    David's          Davids

    Men's            Mens

     

    How to do this.

    Thanks.


    NSG12
    • Edited by NSG12 Friday, April 9, 2010 7:00 PM
    Friday, April 9, 2010 7:00 PM

Answers

  • SELECT REPLACE(OldWord,'''','') AS NewWord
    FROM TableName

    Abdallah El-Chal, PMP, ITIL, MCTS
    • Proposed as answer by Rajendra Kumbar Friday, April 9, 2010 7:11 PM
    • Marked as answer by KJian_ Thursday, April 15, 2010 9:01 AM
    Friday, April 9, 2010 7:03 PM
  • You can use the following syntax, CHAR(39) is single quote:

    SELECT REPLACE('Children''s ',CHAR(39),'')
    -- Childrens 
    
    SELECT REPLACE('Children''s ',CHAR(39)+'s','s')
    -- Childrens 


    Kalman Toth, SQL Server & Business Intelligence Training; SQL 2008 GRAND SLAM

    • Marked as answer by KJian_ Thursday, April 15, 2010 9:01 AM
    Tuesday, April 13, 2010 5:59 AM

All replies

  • SELECT REPLACE(OldWord,'''','') AS NewWord
    FROM TableName

    Abdallah El-Chal, PMP, ITIL, MCTS
    • Proposed as answer by Rajendra Kumbar Friday, April 9, 2010 7:11 PM
    • Marked as answer by KJian_ Thursday, April 15, 2010 9:01 AM
    Friday, April 9, 2010 7:03 PM
  • select replace('Children''s ','''s','s')
    • Proposed as answer by Naomi N Friday, April 9, 2010 7:06 PM
    Friday, April 9, 2010 7:04 PM
  • Thanks.
    NSG12
    Friday, April 9, 2010 7:14 PM
  • You can use the following syntax, CHAR(39) is single quote:

    SELECT REPLACE('Children''s ',CHAR(39),'')
    -- Childrens 
    
    SELECT REPLACE('Children''s ',CHAR(39)+'s','s')
    -- Childrens 


    Kalman Toth, SQL Server & Business Intelligence Training; SQL 2008 GRAND SLAM

    • Marked as answer by KJian_ Thursday, April 15, 2010 9:01 AM
    Tuesday, April 13, 2010 5:59 AM