Sql server REPLACE() question

Discussion in 'Software' started by skb3, Nov 29, 2007.

  1. skb3

    skb3

    Joined:
    Nov 29, 2007
    Messages:
    1
    Likes Received:
    0
    Could anyone help me here I have products in a table, but I need to select a distinct list, the list contains the following:

    Contract Purchase Advance Advance
    Hire Purchase Advance Advance
    Hire Purchase Arrears
    Finance Lease Advance

    In the case of the first couple of lines I need to replace only 1 instance of 'Advance' not both. Is there anyway I could do this, I know the Replace() function does not replace only one instance, i.e.

    Select Replace(ProductNames, 'Advance', '') from ProductList

    Would removed both instances, could anyone help me please?

    Thanks in Advance,

    Steve
     
    skb3, Nov 29, 2007
    #1
    1. Advertisements

  2. skb3

    urstop

    Joined:
    Oct 17, 2007
    Messages:
    11
    Likes Received:
    0
    Location:
    London
    Is the repeated word in this case "Advance" always repeated word after word or it could be anywhere in the data?

    If the repeatition is always word after word you can just modify your statement a bit like below

    Select Replace(ProductNames, 'Advance Advance', 'Advance') from ProductList


    Regards,
    UrStop
     
    urstop, Dec 3, 2007
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.