在未做全文檢索以前,個人主頁只能對Fs_Title(文章標題)字段進行模糊查詢(like '%*%'),如果對內容進行模糊查詢,速度極慢,有時還可能報錯,今天終於有空了,把這個查詢做好了,經過測
試,檢索一萬條紀錄不到兩秒時間。ENJOY~~
復制代碼 代碼如下:
use LuanLuanDB
exec sp_fulltext_database 'enable'
exec sp_fulltext_catalog 'ArtileFullText', 'create', 'E:\SearchPage'
exec sp_fulltext_table 'TArticle', 'create', 'ArtileFullText', 'PK_TArticle'
exec sp_fulltext_column 'TArticle', 'Fs_Title', 'add'
exec sp_fulltext_column 'TArticle', 'Fs_Content', 'add'
exec sp_fulltext_table 'TArticle', 'start_full'
測試代碼:select * from TArticle where Contains(*,'"&key&"') and Fi_IsShow='1' order by Fi_ID DESC