Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Full text Stored procedure

Author  Topic 

Dejan
Starting Member

14 Posts

Posted - 2009-01-03 : 12:25:49
I'm using this procedure to seach in my database:
----------------------
ALTER PROCEDURE [dbo].[Search]
@search nvarchar (250)
as
SELECT *
FROM text
WHERE CONTAINS
(*, @search);
------------------------
When I try to search for only one word I receive results, but when I try to search for 2 or more words, I get error:
----------------------
Msg 7630, Level 15, State 3, Procedure Search, Line 4
Syntax error near 'word' in the full-text search condition 'Word word'.
----------------------
If I put + between the word I get results. How to modify stored procedure to get results for more then one word?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-03 : 13:54:29
try like this and see if it works

ALTER PROCEDURE [dbo].[Search]
@search nvarchar (250)
as
SELECT *
FROM text
WHERE CONTAINS
(*, REPLACE(@search,' ','+');
Go to Top of Page

Dejan
Starting Member

14 Posts

Posted - 2009-01-03 : 14:03:56
Incorrect syntax near 'REPLACE'.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-03 : 14:06:32
quote:
Originally posted by Dejan

Incorrect syntax near 'REPLACE'.


i missed a braces

ALTER PROCEDURE [dbo].[Search]
@search nvarchar (250)
as
SELECT *
FROM text
WHERE CONTAINS
(*, REPLACE(@search,' ','+'));
Go to Top of Page

Dejan
Starting Member

14 Posts

Posted - 2009-01-03 : 14:24:53
Same...
Go to Top of Page

Dejan
Starting Member

14 Posts

Posted - 2009-01-03 : 14:46:57
I'll use it this one TextBox1.Text.Replace(" ", "+") it's work
Go to Top of Page
   

- Advertisement -