February 4, 2009 at 5:59 pm
Hi All,
Can some one please help me with a function to extract a substring between two exact strings.
I have an example for my requirement
DECLARE @mystring VARCHAR(100)
SET @mystring = 'LEFT JOIN Definition.vLocation ON vLocation.ID = vCompany.ID LEFT JOIN Definition.vCountry ON vCountry.ID = vLocation.CountryID'
I want to loop through the string and get the string between JOIN and ON
When i use Patindex('ON', mystring) it does not return the string position and when I use Patindex('%ON%', mystring) it considers the ON in vLocation.
Thanks in Advance
February 4, 2009 at 6:06 pm
APARNA (2/4/2009)
When i use Patindex('ON', mystring) it does not return the string position and when I use Patindex('%ON%', mystring) it considers the ON in vLocation.
[font="Verdana"]Try:
charindex(' ON ', @myString)
[/font]
February 4, 2009 at 6:15 pm
Thank You that works
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply