Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Name search with Full Text Search Expand / Collapse
Author
Message
Posted Monday, January 21, 2013 3:58 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, January 21, 2013 3:52 PM
Points: 1, Visits: 1
Hello.

I'm having trouble implementing a query for searching names on a table PERSON, which has two columns, FORENAME and SURNAME.

I'll use FULL TEXT SEARCH for doing that, and already have created the FULL TEXT CATALOG and the FULL TEXT INDEX on this table.

Supposing that i have the following rows on the table:


1. FORENAME: "Barack" SURNAME: " of Mortal Kombat"
2. FORENAME: "Sadam" SURNAME: "Houssein"
3. FORENAME: "Crystal" SURNAME: "Obakwelu"


And i'm trying to search this name:

. Name to search: "Barack Hussain Obama"



I would do the sql query like this, supposing that @name is a parameter, and it would be passed by the user through the application layer, like a C# program:

declare @name nvarchar(30)
set @name = N'Barack Hussain Obama'

select FORENAME, SURNAME
FROM Person
WHERE CONTAINS( (FORENAME, SURNAME), @name )


How can i get this working? The problem is in the @name string.
ERROR: Syntax error near 'Hussain' in the full-text search condition 'Barack Hussain Obama'.
Post #1409744
Posted Monday, January 21, 2013 11:16 PM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, August 19, 2014 12:26 AM
Points: 2,840, Visits: 3,963
try FREETEXT instead of CONTAINS

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done
Post #1409792
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse