charindex() function lets you find first occurrence of a particular
character in a string.
Is there similar function to find last occurrence of character in
string.
I could use reverse() or some script to find that, but it will be
inefficient.
Could anybody suggest me efficient solution for this.
Thanks and Regards,
AvinAvi, please do not multipost as I have already answered in.programming
group.
"Avi" <avimandale@.gmail.com> wrote in message
news:271710bf-a8dd-4a82-8bc2-076b920d6919@.k39g2000hsf.googlegroups.com...
> charindex() function lets you find first occurrence of a particular
> character in a string.
> Is there similar function to find last occurrence of character in
> string.
> I could use reverse() or some script to find that, but it will be
> inefficient.
> Could anybody suggest me efficient solution for this.
> Thanks and Regards,
> Avin|||On Jan 28, 5:25=A0pm, Avi <avimand...@.gmail.com> wrote:
> charindex() function lets you find first occurrence of a particular
> character in a string.
> Is there similar function to find last occurrence of character in
> string.
> I could use reverse() or some script to find that, but it will be
> inefficient.
> Could anybody suggest me efficient solution for this.
> Thanks and Regards,
> Avin
Hi Avin,
declare @.string1 varchar(50), @.string2 varchar(50)
select @.string1 =3D 'abc', @.string2=3D 'oooabcooabco'
select (datalength(@.string2)-1)-
charindex(reverse(@.string1),reverse(@.string2))
HTH
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment