【问题标题】:sp_executesql along with fulltext search and formsof inflectionalsp_executesql 以及全文搜索和屈折形式
【发布时间】:2013-02-20 02:05:13
【问题描述】:

我正在尝试执行带有全文搜索的 sp_executesql。

此查询运行良好。

exec sp_executesql 
    N'SELECT TOP (@p0)  this_.org_id as y0_, this_.u_Name as y1_, this_.Category as y2_ FROM Organization this_ 
    WHERE contains (this_.u_Name,@p1)'
    ,N'@p0 int,@p1 nvarchar(4000)',
    @p0=1000,@p1=N'service'

但是我必须为单词变体添加一个变形形式,然后看起来参数@p1 现在是空白的,并且查询没有返回任何结果。任何原因 ?如果我将@p1 替换为实际的“服务”一词,一切正常。

exec sp_executesql 
N'SELECT TOP (@p0)  this_.org_id as y0_, this_.u_Name as y1_, this_.Category as y2_ FROM Organization this_ 
WHERE contains (this_.u_Name,''formsOf(inflectional, @p1)'')'
,N'@p0 int,@p1 nvarchar(4000)',
@p0=1000,@p1=N'service'

【问题讨论】:

    标签: sql sql-server full-text-search sp-executesql


    【解决方案1】:

    在 formsOf() 中,您的变量 @p1 变成了一个字符串。试试这个:

    exec sp_executesql 
    N'declare @ft nvarchar(4000)
    set @ft = ''formsof(inflectional, '' + quotename(@p1, ''"'') + '')''
    SELECT TOP (@p0)  this_.org_id as y0_, this_.u_Name as y1_, this_.Category as y2_ FROM Organization this_ 
    WHERE contains (this_.u_Name,@ft)'
    ,N'@p0 int,@p1 nvarchar(4000)',
    @p0=1000,@p1=N'service'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-12
      • 2013-11-10
      • 2018-11-23
      相关资源
      最近更新 更多