Click here to Skip to main content
12,396,230 members (61,850 online)
Rate this:
 
Please Sign up or sign in to vote.
Hi All,

I am facing problem to write search query in sqlserver for search engine.
I have a textbox and button.
I want to search any word on button click through sqlserver query.But this query gives only matching word.
For Example when I enter tata it gives the result but when we enter tata123 it gives no output.

My Sqlserver query is:
"
select distinct top 20 s.title,s.Short_Description,s.primary_keyword,p.cat_id,s.art_id from tbl_summary s inner join tbl_publishinfo as p on p.art_id =s.art_id where s.art_id in(select pi.art_id from tbl_publishinfo pi group by pi.art_id having(count(pi.art_id)=1)) and s.title like'%" & txttext & "%' order by s.art_id desc"
Posted 27-Feb-12 17:19pm
Updated 27-Feb-12 18:24pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Hi,
What you are looking for can be done easily using full text catalog.
This searches for part or complete string on multiple fields.

Have a look on the following links.


Description of Full Text
http://msdn.microsoft.com/en-us/library/ms142571.aspx[^]


How to Use:
http://msdn.microsoft.com/en-us/library/ms142583.aspx[^]
  Permalink  
Comments
Tech Code Freak 28-Feb-12 5:33am
   
5up!
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

for example
 
dim str as string
str= select * from tablename where column name='"&textboxName&"'

try it
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

You need to enable full text search on the target Sql Server success depends on you table design too then create a full text catalog then you can search the way you want to.

Do some Google search or try links given by Mr Ankit

Best of luck
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160721.1 | Last Updated 28 Feb 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100