how to find words between two words in a string


hi

how find words  between 2 words in string in sql

eg 1 word "users" , second word " name1 " in given string

how find "test" in given string

i tried this

declare @str varchar(max)
set @str='dear  afolabi dare fatai  1 of our users test name1 looking cyber description : dsfs.'
select substring (@str,5,9)

 

thanks in advance

try this

declare @str varchar(max)
set @str='dear  afolabi dare fatai  1 of our users test name1 looking cyber description : dsfs.'
select ltrim(rtrim(substring(@str , charindex('users',@str) +len('users'),charindex('name1',@str) - (charindex('users',@str) +len('users')) ) ))

 


http://uk.linkedin.com/in/ramjaddu


SQL Server  >  Getting started with SQL Server



Comments

Popular posts from this blog

SQL Server PSProvider SQL Server Authentication

BIT Version

How to calculate the delta size while diffing the files in TeamFoundationServer ?