【问题标题】:Syntax error when using NEAR with maximum_distance value将 NEAR 与 maximum_distance 值一起使用时出现语法错误
【发布时间】:2013-04-05 11:29:27
【问题描述】:

如何修改此查询以搜索仅相隔两个单词的关键字?

select id, SubjectText from dbo.email  where contains
 ([ContentText],'execute NEAR class near program near code near SQL');

这些是我得到的结果:

id  SubjectText
1   examples for you 
3   Oracle classes starting soon 
4   Toms Hardware nes letter 
5   Registration starts soon  
7   Dreamspark SQL order  ready  
8   SQL classes free online  
10  Visual Basic key  
20  SQL Help   
21  A Free SQL Server Monitoring Package  
22  A Monitoring Package  

试过了:-

select id, SubjectText
from dbo.email
where contains (ContentText,
                'NEAR ((execute, class , program, SQL ,code),2,true)'
               );

但得到错误Msg 7630, Level 15, State 2, Line 2 Syntax error near '(' in the full-text search condition 'NEAR ((execute, class , program, SQL ,code),2,true)';

我试过了

从 dbo.email 中选择 id、SubjectText,其中包含 ([ContentText],'"((近类执行,近程序,近代码,近SQL))"',2,true); 去

从 dbo.email 中选择 id、SubjectText,其中包含 ([ContentText],'near((执行,类,程序代码,SQL))',2,true); 去

从 dbo.email 中选择 id、SubjectText,其中包含 ([ContentText],'(在 SQL 附近的程序 NEAR 代码附近执行附近的类)',2,true); 去

它们都不起作用,它们都会产生错误,请帮助

【问题讨论】:

  • 你有什么版本的 SQL Server?正如documentation 所说,只有 SQL Server 2012 允许您指定搜索词之间的最大距离。
  • 我使用的是 2008,我升级了,我的查询工作正常。感谢所有的帮助。
  • 很高兴我能帮忙,我重新措辞了你的标题并添加了我的评论作为答案,它可能会让其他人更容易找到这个

标签: sql-server sql-server-2008 tsql full-text-indexing


【解决方案1】:

正如documentation 所说,只有 SQL Server 2012 允许您指定搜索词之间的最大距离,因此如果您使用的是 SQL Server 2008,则会收到此错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-20
    • 1970-01-01
    • 1970-01-01
    • 2022-07-01
    • 1970-01-01
    • 2021-06-25
    • 2018-06-16
    相关资源
    最近更新 更多