Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Searching company name in Sql server Stored procedure

Posted on 2008-10-02
4
Medium Priority
?
201 Views
Last Modified: 2010-03-20
I need a search query stored procedure through which I can check a particular search criteria using keyword, particular word or some phrase. For e.g. my company name is "Experts exchange india pvt ltd". Now if I search with a keyword like "Experts" then it should show all the companies listing with keyword Experts in it.  Now suppose I search with "Experts India ltd" then also it should show the same results with the companies with the same names listing. Can you please provide me some stored procedure or query for this?
0
Comment
Question by:Gurbirs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 16

Expert Comment

by:brad2575
ID: 22622948
Yes just use

Select * From CompanyTable
where CompanyName like '%Experts%'

The like and any text in the middle of the 2 "%%" act as wild cards so it will find anything in a field that is like what you are looking for.
0
 

Author Comment

by:Gurbirs
ID: 22622971
But if the company name is Experts Pvt. then it is showing nothing. Can you suggest?
0
 

Author Comment

by:Gurbirs
ID: 22622977
I mean the company name is  Experts India Pvt ltd and the keyword searchd is "Experts Ltd", here it is not showing anything
0
 
LVL 16

Accepted Solution

by:
brad2575 earned 1500 total points
ID: 22623165
The search I described would not work then.  You would have to break the search string up by spaces and do a where like '%%' for each part of the search string.

So you would do this:
WHere CompanyName like '%Experts%' AND CompanyName like '%Ltd%'

Depending on the language you are using to code in you would have to build the where clause in different ways.  You could split the search string up by spaces into an array and loop the array to dynamically build the where clause like above.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question