please click arrow to the left for Drop CREATE Data
drop table Temp
go
create table Temp (id int, Rate nvarchar(500), Value_Expected int)
go
insert into Temp values
('1', '1 x E1 (L),As above (E1) but xyz (inflated rate),5.77 6 x E10(L),As above (E10) but xyz (vvv rate),1.235 1 x E11(L),As above (E11) but xyz (vvv rate),0.93',14.11),
('2', '1 x E1,"xyz, new spur, xyz/water/xyz (if required), xyz (xyz)",4.67 1 x E10,Day rate per hour,1 ',5.67),
('3', '1 x E1,"z, z, z gas/water/z (if required), z (z)",4.67 1 x E6b,z (z)11 - 20m,2 1 x E6c,z (z) 21 - 30m,3 1 x E7b,xyz (z)11 - 20m,2 1 x E8,z,0.5 2 x E10,z,1 1 x E11,z,0.75',6.34)
go
select * from Temp
go
Here's the cursor .. going though character by character ...
declare @string varchar(500) = '' , @i int , @Cursor as CURSOR;
set @Cursor = cursor for select rate from temp
open @Cursor; FETCH NEXT FROM @Cursor INTO @string
WHILE @@FETCH_STATUS = 0
BEGIN
select @i = 0
while @i < len(@string)
begin
select @i = @i + 1
select substring(@string, @i, 1)
end
FETCH NEXT FROM @Cursor INTO @string
END
CLOSE @Cursor;
DEALLOCATE @Cursor;