Creating a stored procedure in SQL Server 2008 that will do a "facebook search"

Posted by dig on Stack Overflow See other posts from Stack Overflow or by dig
Published on 2010-06-07T23:30:56Z Indexed on 2010/06/07 23:32 UTC
Read the original article Hit count: 208

Hello,

I'm trying to implement a facebook search in my system (auto suggest while typing). I've managed to code all the ajax stuff, but I'm not sure how to query the database.

I've created a table called People which contains the fields: ID, FirstName, LastName, MiddleName, Email. I've also created a FTS-index on all those fields.

I want to create a stored procedure that will get as a parameter the text inserted in the query box and returns the suggestions.

For example, When I will write in the textbox the query "Joh Do" It will translate to the query:

select * from People where contains(*, '"Joh*"') and contains(*, '"Do*"')

Is there a way to do that in stored procedure?

P.S I've tried to use the syntax

select * from People where contains(*,'"Joh*" and "Do*"')

but it didn't returned the expected results, probably because it needs to search the words on different fields. Is there a way to fix that?

Thanks.

© Stack Overflow or respective owner

Related posts about sql-server-2008

Related posts about stored-procedures