This one (without use of cursor or loops opr UDF) will perform and scale much better...
declare @pInput varchar(max)
declare @n int
set @pInput = '1:1,3,5,7,4:56,43,58,5:34,67r,234'
set @pInput = ',' + @pInput + ','
select @n =LEN(@pInput)
set rowcount @n
select IDENTITY( int,1,1) as id into #tally
from sys.columns
set rowcount 0
declare @val1 varchar(500)
declare @res table (id int, vals varchar(1000), val1 varchar(500), val2 varchar(500))
insert into @res (id, vals)
select id
,SUBSTRING(@pInput,id+1,CHARINDEX(',',@pInput,id+1)-id-1) vals
from #tally
where SUBSTRING(@pInput,id,1) = ',' and id < LEN(@pInput)
update @res
set val1 = case when CHARINDEX(':', vals) > 0 then SUBSTRING(vals,0,CHARINDEX(':', vals)) else @val1 end
,val2 = case when CHARINDEX(':', vals) > 0 then SUBSTRING(vals,CHARINDEX(':', vals)+1,1000) else vals end
,@val1 = case when CHARINDEX(':', vals) > 0 then SUBSTRING(vals,0,CHARINDEX(':', vals)) else @val1 end
select val1, val2 from @res
drop table #tally
If your string to split expected to be very large, you can add clustered unique index on id column of #tally table and use # table instead of table variable for the result table. Otherwise, I think this code is fine as it is...