Apostrophe - How to replace in a string

  • Through the search function here, I found how to filter for all occurances of an apostrophe in a column. Example:

    select *

    from nameaddress

    where [name] like '%''%'

    But how can I replace them all with blanks? Can I do it with the replace function?

    This does not work:

    replace([name],'%''%','')

    Thank you.

  • This should work for you.

    Declare @testtable table(name varchar(40))

    Declare @string varchar(40)

    Set @string = 'This is a test of the '''

    Insert into @testtable (name)

    Select @string

    select *

    from @testtable

    where [name] like '%''%'

    select replace([name],'''',''' Has been replaced')

    From @testtable

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply