【问题标题】:Search for forward slash within a SQL Server Full Text Index using Contains使用包含在 SQL Server 全文索引中搜索正斜杠
【发布时间】:2015-01-17 11:56:14
【问题描述】:

我有一个 SQL Server 全文索引,我正在尝试使用 CONTAINS 搜索短语,例如数据中包含的 /cap。但是,SQL Server 似乎去掉了/,只返回包含cap 的结果。如何阻止这种情况发生,以便我可以准确地返回我正在搜索的内容?

【问题讨论】:

标签: sql-server full-text-search special-characters contains


【解决方案1】:

请使用like运算符

CREATE TABLE temp(
   sometext nvarchar(100)
)

INSERT INTO temp

SELECT 'I contain /cap and cap'
UNION ALL
SELECT 'Dummy'
UNION ALL
SELECT 'CAP'

SELECT sometext FROM temp
WHERE sometext LIKE '%/cap%'

SELECT sometext FROM temp
where sometext like '%cap%'

结果:

sometext
--------
I contain /cap and cap

sometext
--------
I contain /cap and cap
CAP

【讨论】:

  • 因此首先否定了使用全文的全部意义。
猜你喜欢
  • 2011-02-08
  • 1970-01-01
  • 2016-02-14
  • 1970-01-01
  • 1970-01-01
  • 2022-10-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-26
相关资源
最近更新 更多