SQL2005实现全文检索的步骤 停止数据库的用户连接
生活随笔
收集整理的這篇文章主要介紹了
SQL2005实现全文检索的步骤 停止数据库的用户连接
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
--停止數(shù)據(jù)庫的用戶連接
create?proc killspid (@dbname?varchar(50))?
as??
declare?@sql?nvarchar(1000), @spid?int??
declare getspid? cursor?for? select spid from sysprocesses?
where dbid=db_id(@dbname)????
open getspid??
fetch?next?from getspid into?@spid??
while?@@fetch_status=0??
begin?
???? exec('kill '+@spid)????????
???? fetch?next?from getspid into?@spid??
end??
close getspid??
deallocate getspid?
go?
--用法
use master??
exec killspid '數(shù)據(jù)庫名'?
select*fromwhere*'test'優(yōu)化后性能提升?2倍+select?*?from?Table1?where?Contains((Content,Title),'test')
create?proc killspid (@dbname?varchar(50))?
as??
declare?@sql?nvarchar(1000), @spid?int??
declare getspid? cursor?for? select spid from sysprocesses?
where dbid=db_id(@dbname)????
open getspid??
fetch?next?from getspid into?@spid??
while?@@fetch_status=0??
begin?
???? exec('kill '+@spid)????????
???? fetch?next?from getspid into?@spid??
end??
close getspid??
deallocate getspid?
go?
--用法
use master??
exec killspid '數(shù)據(jù)庫名'?
?
?
SQL2005實現(xiàn)全文檢索的步驟是什么? 與SQL2000的全文檢索實現(xiàn)有什么不同? 答案: 具本步驟為(括號內(nèi)為每步所調(diào)用的存儲過程名稱): (1)啟動數(shù)據(jù)庫的全文處理功能(sp_fulltext_datebase); (2)建立全文目錄(sp_fulltext_catalog); (3)在全文目錄中注冊需要全文索引的表(sp_fulltext_table); (4)指出表中需要全文檢索的列名(sp_fulltext_column) (5)為表創(chuàng)建全文索引(sp_fulltext_table); (6)填充全文索引(sp_fulltext_catalog)。 例: use pubs go exec sp_fulltext_database 'enable' --為titles表建立全文索引數(shù)據(jù)元,其中create為建立,activate為激活,deactivate為關(guān)閉表全文索引的激活狀態(tài),使 它不再參加全文目錄填充,drop為刪除;create參數(shù)中,后面跟的是全文目錄名稱和索引列名。 --下面語句為pubs數(shù)據(jù)庫中的titles表創(chuàng)建全文索引數(shù)據(jù)元,存儲該數(shù)據(jù)元的全文目錄為FT_pubs,所使用的唯一索引為 UPKCL_titleidind(title表中為title_id列的PRIMARY KEY約束所建立的唯中索引) sp_fulltext_table titles,'create','FT_pubs','upkcl_titledind' --激活它 sp_fulltext_table titles,'activate' --指定參加全文索引的列 sp_fulltext_column 'titles','title','add' sp_fulltext_column 'titles','notes','add' 下面是一個完整的例子: --在執(zhí)行該腳本程序之前啟動sql server的全文搜索服務(wù),即microsoft search服務(wù) use pubs --打開數(shù)據(jù)庫 go --檢查pubs是否支持全文索引,如果不支持全文索引,則使用sp_fulltext_datebase打開該功能 if (select databaseproperty ('pubs','IsFulltextEnables'))=0 execute sp_fulltext_database 'enable' --建立全文目錄FT_pubs execute sp_fulltext_catalog 'FT_pubs','create' --為titles表建立全文索引數(shù)據(jù)元 execute sp_fulltext_table 'titles','FT_pubs','UPKCL_titleidind' --設(shè)置全文索引列名 execute sp_fulltext_column 'titles','title','add' execute sp_fulltext_column 'titles','notes','add' --建立全文索引 execute sp_fulltext_table 'FT_pubs','activate' --填充全文索引目錄 execute sp_fulltext_catalog 'FT_pubs','start_full' GO --檢查全文目錄填充情況 WHILE FulltextCatalogProperty("FT_pubs','PopulateStatus')<>0 BEGIN --如果全文目錄正處于填充狀態(tài),則等待30秒后再檢測一次 WAITFOR DELAY ‘0:0:30’ END --全文目錄填充完成后,使用全文目錄檢索 --查詢title列或notes列中包含有database或computer字符串的圖書名稱 SELECT title FROM title where CONTAINTS(title,'database') or contains(notes,'database') or contains(title,'computer') or contains(notes,'computer')select*fromwhere*'test'優(yōu)化后性能提升?2倍+select?*?from?Table1?where?Contains((Content,Title),'test')
?
轉(zhuǎn)載于:https://www.cnblogs.com/zengxiangzhan/archive/2010/01/03/1638164.html
總結(jié)
以上是生活随笔為你收集整理的SQL2005实现全文检索的步骤 停止数据库的用户连接的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 批处理判断文件夹是否存在
- 下一篇: 发现数据对象 -- 数据库开发的关键