Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
skb3
Starting Member
2 Posts |
Posted - 2007-11-29 : 06:29:03
|
| 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 AdvanceHire Purchase Advance AdvanceHire Purchase ArrearsFinance Lease AdvanceIn 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 ProductListWould removed both instances, could anyone help me please?Thanks in Advance,Steve |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-11-29 : 07:17:05
|
| Tryselect case when ProductNames like '%advance advance%' then replace(ProductNames,'advance advance','advance') else replace(ProductNames ,'advance','') end from ProductListMadhivananFailing to plan is Planning to fail |
 |
|
|
skb3
Starting Member
2 Posts |
Posted - 2007-11-29 : 09:04:01
|
| Thanks very much Madhivanan, that's a great idea, I have a few extra case statements, but I have it all working now. Fantastic. |
 |
|
|
|
|
|
|
|