add values inside a * delimited string sql server 2008

I've a situation here, i need to add the values inside a table field. the values in that field is * delimited for example 160.00*120.00*****************************. my sql is very simple and straightforward as below.

SELECT Ref, (left(DateOfServiceFrom,10)+ '-' +right(REPLACE(DateOfServiceTo, '*', ''),10)) AS Episodes,  ServiceCharges, DateClaimSent
    FROM Claim

Open in new window

ServiceCharges = 160.00*120.00*****************************

so when i run my query, ServiceCharges value need to come 280.00. In some cases the values are also vary like 160.00*120.00**********20.00******************
so in that case, the ServiceCharges value should be 300.00.
i wrote the select statement
select replace (rtrim(replace('160.00*120.00*****************************','*',' ')),' ','+') AS PLUSDELIMVALUES

Open in new window

but the result come as 160.00+120.00
any help, comment or feedback would be deeply appreciated.
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

appariConnect With a Mentor Commented:
try this using XML data type.

This code returns 280.00
sum(n.r.value('.', 'decimal(12,2)'))
from (
select cast('<r>'+ replace('160.00*120.00*****************************','*','</r><r>') + '</r>' as xml)) as
cross apply S.XMLCol.nodes('r') as n(r)
where n.r.value('.', 'varchar(10)') <> ''

Open in new window

try applying same logic in your query,
SELECT Ref, (left(DateOfServiceFrom,10)+ '-' +right(REPLACE(DateOfServiceTo, '*', ''),10)) AS Episodes,  
 DateClaimSent, sum(n.r.value('.', 'decimal(12,2)'))
    FROM Claim 
cross apply (
select cast('<r>'+ replace(ServiceCharges,'*','</r><r>') + '</r>' as xml)) as S(XMLCol)
cross apply S.XMLCol.nodes('r') as n(r)
where n.r.value('.', 'varchar(1)') <> ''
Group by Ref, (left(DateOfServiceFrom,10)+ '-' +right(REPLACE(DateOfServiceTo, '*', ''),10)) ,

Open in new window

should mention i got the idea of using XML from another question:
All Courses

From novice to tech pro — start learning today.