Wednesday, 30 September 2015

substring , reverse and charindex


declare @s varchar(200);

set @s='F9ADD13F-B055-497B-83CB-ECF6CEE29C0E;163;AAA Concrete;Payment;10.00;Cash;2015-07-23;(Payment) 10.00 Cash - AAA Concrete;24;'
declare @a varchar(200);
declare @b varchar(200);
declare @c varchar(200);
declare @d varchar(200);
declare @e varchar(200);
declare @f varchar(200);
declare @g varchar(200);
declare @h varchar(200);


set @a=       SUBSTRING(@s, charindex(';', @s)+1, len(@s) )

--select @a;

set @b=   SUBSTRING(@a,CHARINDEX(';',@a)+1 ,len(@a))

set @c=   SUBSTRING(@b,CHARINDEX(';',@b)+1 ,len(@b))

set @d=   SUBSTRING(@c,CHARINDEX(';',@c)+1 ,len(@c))

--select @d;
set @e=SUBSTRING(@d,0,CHARINDEX(';',@d) )

select @e;

set @f= SUBSTRING(REVERSE(@s),2,len(@s))



set @g= REVERSE(SUBSTRING(@f, 1, charindex(';', @f)-1))


select @g;




No comments:

Post a Comment