Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Other Technologies / Full-Text Search / April 2008

Tip: Looking for answers? Try searching our database.

searching across multiple columns

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andrew Jocelyn - 18 Mar 2008 20:08 GMT
Hi

I've seen lots of posts on this subject but no satisfactory answers. I asked
the question in 2004 before SQL 2005 arrived so I wondered if there is a
neat solution to this problem now. I want a way to get return one row from
the query below.

CREATE TABLE Users
(
UID int IDENTITY(1000,1) PRIMARY KEY,
FirstName varchar(50) DEFAULT '' NOT NULL,
LastName varchar(50) DEFAULT '' NOT NULL
)

INSERT INTO Users(FirstName, LastName) VALUES('John', 'Smith')
INSERT INTO Users(FirstName, LastName) VALUES('Bob', 'Smith')
INSERT INTO Users(FirstName, LastName) VALUES('John', 'Brown')
INSERT INTO Users(FirstName, LastName) VALUES('Bob', 'Brown')

SELECT UID, FirstName, LastName FROM Users
WHERE CONTAINS (*, 'John AND Smith')

The problem with this technique below is I don't know how many words are
going to be searched.

SELECT UID, FirstName, LastName FROM Users
WHERE CONTAINS (*, 'John') and CONTAINS (*, 'Smith')

I thought about concatenating columns in a view but I can't see how I can
get that to work. FREETEXT gives me two many answers too. Someone suggested
a trigger which adds the concatenated columns to another text column for
full-text indexing. It seems like it might be the best option at the moment
but it seems messy to me.

Thanks
Andrew
Randeep Sawhney - 08 Apr 2008 16:44 GMT
Your technique is fine. Thsi is how you should do.

As far as the no of words - you can always break the words and add AND
between them before executing it.

for e.g. - i someone enters John Smith Randers in the textbox, you
programmtically add AND in between the words such as it becomes "John AND
Smith AND Randers"

I am trying to point you into the right direction ... rest is for you to do.

This is exactly how i am doing in one of my projects.

Cheers
Randeep

> Hi
>
[quoted text clipped - 32 lines]
> Thanks
> Andrew
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.