我正在尝试创建FREETEXTTABLE。我得到了以下错误。
Msg 7601,16级,状态2,第1行
不能在表或索引视图“标志”上使用包含或FREETEXT谓词,因为它不是全文索引的.
我的样本
CREATE TABLE Flags (Country nvarchar(30) NOT NULL, FlagColors varchar(200));
CREATE UNIQUE CLUSTERED INDEX FlagKey ON Flags(Country);
INSERT Flags VALUES ('France', 'Blue and White and Red');
INSERT Flags VALUES ('Italy', 'Green and White and Red');
INSERT Flags VALUES ('Tanzania', 'Green and Yellow and Black and Yellow and Blue');
SELECT * FROM Flags;
GO
CREATE FULLTEXT CATALOG TestFTCat;
CREATE FULLTEXT INDEX ON Flags(FlagColors) KEY INDEX FlagKey ON TestFTCat;
GO
SELECT * FROM FREETEXTTABLE (Flags, FlagColors, 'Blue');发布于 2015-10-06 10:47:52
验证是否安装了MSSQL 2008的全文“组件”的简单方法是执行以下MSSQL
SELECT SERVERPROPERTY('IsFullTextInstalled')如果返回的值为“1”,则会安装组件。
否则,必须在现有Server实例上安装安装Server全文搜索。
现在您可以使用T启用全文搜索。
-- We'll use Northwind sample database to enable
-- Full Text Search feature using T-SQL code only
USE Northwind
GO
-- We need to enable full text search for Northwind database
-- We will do that with sp_fulltext_database procedure
EXEC sp_fulltext_database 'enable'
-- Create catalog
EXEC sp_fulltext_catalog 'NorthwindCatalog','create'
-- Add some indexes to database
EXEC sp_fulltext_table 'Customers', 'create', 'NorthwindCatalog', 'pk_customers'
EXEC sp_fulltext_table 'Orders', 'create', 'NorthwindCatalog', 'pk_orders'
-- add columns for searching to full text search index
EXEC sp_fulltext_column 'Customers', 'CompanyName', 'add'
EXEC sp_fulltext_column 'Customers', 'ContactName', 'add'
EXEC sp_fulltext_column 'Customers', 'Address', 'add'
EXEC sp_fulltext_column 'Customers', 'City', 'add'
EXEC sp_fulltext_column 'Orders', 'ShipName', 'add'
EXEC sp_fulltext_column 'Orders', 'ShipAddress', 'add'
EXEC sp_fulltext_column 'Orders', 'ShipCity', 'add'
-- Activate full text search indexes
EXEC sp_fulltext_table 'Customers','activate'
EXEC sp_fulltext_table 'Orders','activate'
-- start full population of catalog
EXEC sp_fulltext_catalog 'NorthwindCatalog', 'start_full'现在,您可以使用CONTAINSTABLE包含、FREETEXT、或FREETEXTTABLE关键字对索引列执行搜索。例如,假设我想检查所有联系人,其中的名字是Maria或Ana:
USE Northwind
GO
SELECT CustomerId, ContactName, CompanyName, Address, City
FROM Customers c INNER JOIN
CONTAINSTABLE(Customers, (ContactName), '"Maria" OR "Ana"') AS KEY_TBL
ON c.CustomerId = KEY_TBL.[KEY]
ORDER BY KEY_TBL.RANK DESC此SQL查询将返回结果,如下图所示:

发布于 2015-10-05 12:21:04
下面的代码部分不知怎么没有在数据库上执行请先执行下面的命令,然后使用FreeTextTable
CREATE FULLTEXT CATALOG TestFTCat;
CREATE FULLTEXT INDEX ON Flags(FlagColors) KEY INDEX FlagKey ON TestFTCat;https://stackoverflow.com/questions/32946523
复制相似问题