MS sqlserver全文管理与全文查询结合的示例
来源:互联网 发布:上海银行淘宝普卡好吗 编辑:程序博客网 时间:2024/04/30 09:10
全文索引可以使用 SQL Server 企业管理器或存储过程进行管理。有时候,将全文管理存储过程结合在进行查询的同一个脚本中是很方便的。下面的脚本范例就结合了这两个任务:
- 创建并填充一个表。
- 将 pubs 数据库启用全文检索。
- 创建全文目录。
- 注册新表及其中的某些列,以进行全文检索。
- 用新表中的全文索引信息填写新的全文目录。
- 对新表执行全文查询。
USE pubs-- Create and populate a table.IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'FulltextTest') DROP TABLE FulltextTestGOCREATE TABLE FulltextTest ( article_id int IDENTITY(100,1) CONSTRAINT PK_title_id PRIMARY KEY, article_title nvarchar(200) )GOINSERT FulltextTest (article_title) VALUES (N'Steven Buchanan has always enjoyed ice skating.')INSERT FulltextTest (article_title) VALUES (N'Elvis Stoiko: The best male figure skater')INSERT FulltextTest (article_title) VALUES (N'Steven Buchanan On Ice: Skating Reaches Tops in Public Opinion Poll')INSERT FulltextTest (article_title) VALUES (N'Last night, Steven Buchanan skated on the ice!! Skating fans cheer!')INSERT FulltextTest (article_title) VALUES (N'Ice-skating brings out the best in Steven. Buchanan exults in first victory...')GO-- Enable full-text searching in the database.EXEC sp_fulltext_database 'enable'GO-- Create a new full-text catalog.EXEC sp_fulltext_catalog 'StevenBCatalog', 'create' GO-- Register the new table and column within it for full-text querying, -- then activate the table.EXEC sp_fulltext_table 'FulltextTest', 'create', 'StevenBCatalog', 'PK_title_id'EXEC sp_fulltext_column 'FulltextTest', 'article_title', 'add'EXEC sp_fulltext_table 'FulltextTest', 'activate'GO-- Start full population of the full-text catalog. Note that it is-- asynchronous, so delay must be built in if populating a-- large index.EXEC sp_fulltext_catalog 'StevenBCatalog', 'start_full'WHILE (SELECT fulltextcatalogproperty('StevenBCatalog','populatestatus')) <> 0 BEGIN WAITFOR DELAY '00:00:02' -- Check every 2 seconds to see if full-text index population is complete. CONTINUEENDGO-- Execute a full-text query against the new table.SELECT article_titleFROM FulltextTestWHERE CONTAINS(article_title, ' "Steven Buchanan" AND "ice skating" ')
下面是结果集:
article_title ------------------------------------------------------------------------ Steven Buchanan has always enjoyed ice skating.Last night, Steven Buchanan skated on the ice!! Skating fans cheer!Steven Buchanan On Ice: Skating Reaches Tops in Public Opinion PollIce-skating brings out the best in Steven. Buchanan exults in first victory...(4 row(s) affected)
- MS sqlserver全文管理与全文查询结合的示例
- SQLSERVER全文查询构架
- SQLSERVER数据库全文索引示例
- SQLSERVER数据库全文索引示例
- 全文索引的示例
- 全文索引原理及其示例(sqlserver)
- 关于SQLSERVER的全文目录跟全文索引的区别
- 关于SQLSERVER的全文目录跟全文索引的区别
- Solr与数据库结合实现全文检索
- MS SQL Server 对文件内容进行全文检索的查询
- MS SQL Server 对文件内容进行全文检索的查询
- MS SQL Server 对文件内容进行全文检索的查询
- sqlserver中全文检索与csw(测试版)实现分词查询测试
- sqlserver启动images字段的全文检索
- 手工启用SQLServer数据库的全文索引
- SQLSERVER全文索引的一个BUG
- SqlServer全文搜索中文出错的问题
- sqlserver 全文检索
- JavaScript转换农历类
- Window系统小设置
- FusionCharts中的多语言字符使用方法
- android:allowTaskReparenting(clearTaskOnLaunch...)
- 从vi中incsearch得到的
- MS sqlserver全文管理与全文查询结合的示例
- UITableView的cellForRowAtIndexPath方法被不必要的调用很多次的问题
- oracle转义字符总结
- C#web便捷插件开发
- jquery操作select(取值,设置选中)
- 【JSP】表单提交与表单验证
- java后台跳转
- oracle什么时候需要commit
- Oracle数据库备份与恢复之完全攻略