创建数据库
CREATE DATABASE 数据库名
创建表
CREATE TABLE tblFullTextIndex
(
ID INT PRIMARY KEY IDENTITY(1,1),
NAME VARCHAR(100)
)
给表添加内容
INSERT INTO tblFullTextIndex(NAME) VALUES ('ASD')
INSERT INTO tblFullTextIndex(NAME) VALUES ('张三')
INSERT INTO tblFullTextIndex(NAME) VALUES ('王五')
INSERT INTO tblFullTextIndex(NAME) VALUES ('李四')
INSERT INTO tblFullTextIndex(NAME) VALUES ('苏六')
INSERT INTO tblFullTextIndex(NAME) VALUES ('杜七')
创建全文索引
测试全文索引
SELECT * FROM tblFullTextIndex WHERE CONTAINS(NAME,'李')
SELECT * FROM tblFullTextIndex WHERE CONTAINS(NAME,'A')
注意:事实上记录中有包含“A”的,却搜索不出来,因为默认的断词语言是简体中文,所以英文搜索不出来!