create table #xml_tbl ( tag varchar(255) null)
insert #xml_tbl values(
'
A sample doc
This is just a sample para
Now this para contains some interesting text
And this is really boring
Some footer text
') /* 123456 7890123456789012345678901234 A sample doc 1234567890123456789012345678901234567890 This is just a sample para 1234567890123456789012345678901234567890123456789012345678 Now this para contains some interesting text 123456789012345678901234567890123456789 And this is really boring 1234567890123456789012345678901234
Some footer text
1234567
*/ declare @search_str varchar(30), @Search_Word varchar(30) set @Search_Word = 'just' set @search_str = '%' + @Search_Word + '%' select patindex(@Search_Str, tag), charindex('', tag, patindex(@Search_Str, tag)), patindex(reverse(@Search_Str), reverse(tag)), charindex(reverse(''), reverse(tag), patindex(reverse(@Search_Str), reverse(tag))), reverse(substring(reverse(tag), patindex(reverse(@Search_Str), reverse(tag)), charindex(reverse(''), reverse(tag), patindex(reverse(@Search_Str), reverse(tag))) - patindex(reverse(@Search_Str), reverse(tag)) + len(''))) + substring(tag, patindex(@Search_Str, tag) + len(@Search_Word), charindex('', tag, patindex(@Search_Str, tag)) - patindex(@Search_Str, tag) + len('') - len(@Search_Word)) from #xml_tbl
This page was last updated on May 01, 2006 04:28 PM.