sqlserver 实现数据库全文检索
2024-09-07 12:27:25
--在执行该脚本程序之前启动sql server的全文搜索服务,即microsoft search服务
use huarui_db --打开数据库
go
--检查huarui_db是否支持全文索引,如果不支持全文索引,则使用sp_fulltext_datebase打开该功能
if (select databaseproperty ('huarui_db','IsFulltextEnables'))=0
execute sp_fulltext_database 'enable'
--建立全文目录FullText_huarui_db
execute sp_fulltext_catalog 'FullText_huarui_db','create'
--为Products表建立全文索引数据元
execute sp_fulltext_table 'Products','create','FullText_huarui_db','PK_Products' --设置全文索引列名
execute sp_fulltext_column 'Products','Product_name','add'
execute sp_fulltext_column 'Products','Product_type','add'
execute sp_fulltext_column 'Products','Category_name','add'
execute sp_fulltext_column 'Products','Memo1','add'
--建立全文索引
--execute sp_fulltext_table 'FullText_huarui_db','activate'
--填充全文索引目录
execute sp_fulltext_catalog 'FullText_huarui_db','start_full' GO
--检查全文目录填充情况
WHILE FulltextCatalogProperty('FullText_huarui_db','PopulateStatus')<>0
BEGIN
--如果全文目录正处于填充状态,则等待30秒后再检测一次
WAITFOR DELAY '0:0:30'
END
--全文目录填充完成后,使用全文目录检索
--查询title列或notes列中包含有database或computer字符串的图书名称
SELECT *
FROM Products
where contains(Product_name,'%1806%')
or contains(Product_type,'%1806%')
最新文章
- Magnifier笔记
- Java中基本数据类型的对比记忆
- U-Boot命令大全(功能参数及用法)
- [Effective JavaScript 笔记]第49条:数组迭代要优先使用for循环而不是for...in循环
- 免杀ASP一句话
- foreach 相关
- expect批量分发公钥
- BZOJ 1015 [JSOI2008]星球大战starwar
- CLR执行模型与常见的几个概念
- node环境安装(mac版和windows版)
- CentOS(linux发行版)系统安装中文输入法:
- Windows 10 安装 Docker for Windows
- 点击table中的某一个td,获得这个tr的所有数据
- C# 小算法1
- docker+elasticsearch的安装
- freeRTOS中文实用教程3--中断管理之延迟中断处理
- 揭开Future的神秘面纱——任务执行
- MVC的注意事项及开发技巧
- python编辑选课系统
- 17monipdb根据IP获得区域