Monday, March 26, 2012

NOOPS in SQL query

Hello DBA's:
I need to exclude some words while doing a string comparison to get a good result. I do not need words like The, Of, And, In while comparing two strings. In short the record
The ABC Company OF XYZ
should match with BOTH
1. ABC
2. Company XYZCould you give us a bit more info of what you wanted to do? Or post your query if you can?|||You could use function replace() for deleting all 'noise' words. List of 'noise' words you can find \Mssql\Ftdata\Sqlserver\Config if Full-Text Search is installed.|||You can use the full text search feature of MS Sql server to do this kind of search operations.|||Have you looked into using the 'CONTAINS' clause?

You can do something like:

SELECT CompanyName
FROM Companies
WHERE CONTAINS(CompanyName, ' "ABC" OR "company" NEAR "XYZ" ')
GO

(You have to have FullText Indexing turned on for this to work)

No comments:

Post a Comment