日期:2014-05-19  浏览次数:20508 次

全文索引问题?
CREATE   PROCEDURE   pro_fulltext_search  
@searchKey   varchar(50)
  AS
set       nocount       on  

select   *   from   titles   contains(title,@searchKey)

上面的代码会有错误提示:156   contains附近有语法错误。

如何让contains(title,@searchKey)   中的@searchKey值的两边加上 ' '呢?

------解决方案--------------------
CREATE PROCEDURE pro_fulltext_search @searchKey varchar(50)
AS
set nocount on
exec( 'select * from titles contains(title, ' ' '+@searchKey+ ' ' ') ')
------解决方案--------------------
declare @sql varchar(8000)
set @sql =
'select * from titles contains(title, ' ' '+@searchKey+ ' ' ') '
exec (@sql)
------解决方案--------------------
Create Proc pro_fulltext_search (
@searchKey varchar(50)
)
AS
set nocount on
set @searchKey= ' "* '+@searchKey+ '* " '
select * from titles contains(title,@searchKey)

go