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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Return Partial Summary in Select

Author  Topic 

jfine
Starting Member

1 Post

Posted - 2011-05-11 : 19:39:52
So query something like

select id,lastname,unknownfield
from tablename
where notes like '%reservation%'


But I would like results to be:

id   lastname   unknownfield
1 Jones ...he made a reservation last winter...


where unknownfield somehow returns something like 25 chars before and after where text was found.

I know I might do a sub select, but it would be nice if full text search had some attributes besides rank and key.

IIS Index service has a nice summary feature that does just this when searching text within files.

.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-05-12 : 03:23:56
Try this

select id,lastname,substring(unknownfield,charindex('reservation',unknownfield)-25,charindex('reservation',unknownfield)+25)
from tablename
where notes like '%reservation%'


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -