Solved

Search by any word!

Posted on 1998-07-20
2
199 Views
Last Modified: 2010-03-19
I want to know how to write the SQLQuery that it can search in the table by any word!
0
Comment
Question by:ruisun
2 Comments
 
LVL 2

Accepted Solution

by:
odessa earned 50 total points
ID: 1091801
very dificult question if you want to search whole table for a word (for example "KILE") do some like this:
select * from TABLE
where
(FILED1 like "%KILE%") or
(FILED2 like "%KILE%") or
(FILED3 like "%KILE%") ...


. some like this this is the only way
0
 
LVL 1

Expert Comment

by:mativare
ID: 1091802
In MSSQL server 7.0 beta you can use full text indexing with
Contains
Contains is powerful keyword
This example searches for all products with words of the form "dry": dried, drying, and so on.
(See if you use like dry* over here, it is another story and it returns lot of garbage too)
USE Northwind
GO
SELECT ProductName
FROM Products
WHERE CONTAINS(ProductName, ' FORMSOF (INFLECTIONAL, dry) ')
GO
I cannot do it with 'like'
also it can use Near() function, wich searches word next to given word
[WHERE CONTAINS(ProductName, 'spread NEAR () Boysenberry']
also uses weighted terms
WHERE CONTAINS(Description, 'ISABOUT (spread weight (.8),
    sauces weight (.4), relishes weight (.2) )' )
See it is simple and powerful, it scrolls every row but
with full text indexing it allows to do sophisticated searches fast, before it was possible only in DB2 and Oracle.
I cannot see we can replace all this examples with LIKE
More in MSSQL 7.0 beta Books Online


0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

773 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