SQL Server 2005 全文检索

SQL Server 2005 全文检索

首先确认安装了全文检索组件和服务,主要是Express版本,它默认是不安装的,企业版和开发版默认是安装的


1、允许数据库使用全文索引,
在SQL Server Management Studio中选择要操作的数据库的右键菜单中的属性,在属性窗口中的Files页面,有Use full-text indexing,勾选这个复选框就可以了。

2、创建full-text catalog

create  fulltext catalog catalogname

运行完此命令,会在sql的安装目录下产生一个缓存文件夹:


3、创建唯一索引,对要进行全文检索的表主键创建唯一索引

create   unique   index  indexname  on  talbename(columnname)

4、创建全文索引
根据之前的full-text catalog和unique index在同一表上创建全文索引

create  fulltext  index   on  tablename(column1,colunmn2,)
key   index  indexname  on  catalogname
with  change_tracking auto

5、使用全文检索函数contains,
完成上面的一系列工作后,就可以在查询中使用全文索引函数contains

where   contains ( column ' "a" and "b" not "c" ' )
where   contains ( column ' "abc" ' )
where   contains ( column ' "a" and "b" and "c" ' )
where   contains ( column ' "a" near "b" ' )
where   contains ( column ' formsof(inflectional, "happy") ' )
matches "happy", "happier", "happiest", "happily".

contains ( column ' isabout("computer" weight(0.5), "software" weight(2.0),
"development" weight(10.0)) rankmethod inner product
' )

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值