Sql server REPLACE() question

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

  1. skb3

    skb3

    Joined:
    Nov 29, 2007
    Messages:
    1
    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. Advertising

  2. skb3

    urstop

    Joined:
    Oct 17, 2007
    Messages:
    11
    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. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Whiting
    Replies:
    2
    Views:
    697
    Brian Whiting
    Dec 29, 2005
  2. Aibak
    Replies:
    3
    Views:
    4,233
    Aibak
    Apr 8, 2004
  3. Tommy
    Replies:
    1
    Views:
    1,771
    Mr. Arnold
    Nov 29, 2007
  4. Vicky
    Replies:
    0
    Views:
    669
    Vicky
    Apr 6, 2007
  5. Darrilgibson@gmail.com

    MCITP SQL Server 2005 or SQL Server 2008

    Darrilgibson@gmail.com, Dec 19, 2007, in forum: MCITP
    Replies:
    0
    Views:
    1,431
    Darrilgibson@gmail.com
    Dec 19, 2007
Loading...

Share This Page