CREATE PROCEDURE pro_fulltext_search 
@searchKey varchar(50)
 AS
set   nocount   on select * from titles contains(title,@searchKey)上面的代码会有错误提示:156 contains附近有语法错误。如何让contains(title,@searchKey) 中的@searchKey值的两边加上''呢?

解决方案 »

  1.   

    CREATE PROCEDURE pro_fulltext_search @searchKey varchar(50)
    AS
    set   nocount   on 
    exec('select * from titles contains(title,'''+@searchKey+''')')
      

  2.   

    declare @sql varchar(8000)
    set @sql = 
    'select * from titles contains(title,'''+@searchKey+''')'
    exec (@sql)
      

  3.   

    Create Proc pro_fulltext_search (
    @searchKey varchar(50)
    )
    AS
    set nocount on
    set @searchKey='"*'+@searchKey+'*"'
    select * from titles contains(title,@searchKey) go
      

  4.   

    在存储过程中无法使用 CONTAINS吗?
      

  5.   

    leo_lesley(leo) ( )你的方法语法上可以通过,但是运行的时候
    execute pro_fulltext_search 'base'或
    execute pro_fulltext_search base  base是要找的字符提示错误:execute pro_fulltext_search data
    服务器: 消息 156,级别 15,状态 1,行 1
    在关键字 'contains' 附近有语法错误。