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
')

 

 

注:轉貼,原文出處http://www.cnblogs.com/epjnpe/archive/2007/03/24/686297.aspx

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章