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.
Author |
Topic |
alexjamesbrown
Starting Member
48 Posts |
Posted - 2007-03-07 : 14:36:41
|
Hi there,i have a Full text search on a table... tblProductsI am trying to query it, to search the descriptions of products..this is the code i use (or part of it) strQuery = "Exec spSearchProducts '"&request("keywords")&"'" Set rsProducts = Server.CreateObject("ADODB.Recordset") rsProducts.Open strQuery, conn, 1, 1 'Opened as Read-OnlyspSearchProducts:CREATE PROCEDURE spSearchProducts( @Query VarChar(100) )ASBEGIN SELECT * from tblProducts WHERE FREETEXT(ProductDescription, @Query)ENDI get this error:A variable cannot be used to specify a search condition in a fulltext predicate when accessed through a cursor. Any idea of how to fix it?Alex |
|
rlaubert
Yak Posting Veteran
96 Posts |
Posted - 2007-03-08 : 11:30:48
|
Create a string variable within the stored procedure to hold the select statement then use exec sp_executesqlexample:declare @@str Nvarchar(255)set @@str = 'select * from tblproducts where freetext(productdescription,'+@query+' )'exec sp_executesqlsp_executesql requires the inputs to be unicode.Raymond LaubertMCDBA, MCITP:Administration, MCT |
 |
|
alexjamesbrown
Starting Member
48 Posts |
Posted - 2007-03-08 : 17:29:08
|
Hey,i have this now:-----------------------------CREATE PROCEDURE spSearchProducts( @Query VarChar(100) )ASdeclare @@str Nvarchar(255)BEGINset @@str = 'select * from tblproducts where freetext(productdescription,'+@query+' )' exec sp_executesqlEND------------------------------------however i get this error: Procedure 'sp_executesql' expects parameter '@statement', which was not supplied.so then, i tried this:exec sp_executesql @@strwhich gave me a different error:Incorrect syntax near 'TEST'.TEST was my @Query |
 |
|
|
|
|
|
|