Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
thorv
Starting Member
7 Posts |
Posted - 2006-12-14 : 18:58:18
|
Anyone that have an sample code on how to search in an text, and only select for instance 20 characters before and after the search word.Just like your search Google, they show you the word that you search for, and some word before and after.Thor |
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2006-12-14 : 20:16:13
|
0. read about charindex() and substring() in BOL.1. find the position of your keyword using charindex() if you don't know it already.2. use substring() to get the text surrounding your keyword. http://www.elsasoft.org |
 |
|
thorv
Starting Member
7 Posts |
Posted - 2006-12-15 : 02:41:05
|
Thanks!This is the SQL that I created:SELECT SUBSTRING(note, CHARINDEX('what', note)-20, 50)FROM notes where note like '%what%' |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-12-15 : 03:09:41
|
quote: Originally posted by jezemine 0. read about charindex() and substring() in BOL.1. find the position of your keyword using charindex() if you don't know it already.2. use substring() to get the text surrounding your keyword. http://www.elsasoft.org
You start with 0 MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|