hubbledotnet 定时更新索引

文章:http://www.cnblogs.com/eaglet/archive/2010/08/25/1808143.html

这里用的是update模式创建表

1、首先在数据库中创建触发器表 

CREATE TABLE [HBTrigger_job_SearchKey] (

[Serial] [bigint]  IDENTITY (1, 1)  NOT NULL,

[Id] [intNOT NULL,

[Opr] [char]  (16) NULL,

[Fields] [nvarchar]  (4000) NULL)

 

ALTER TABLE [HBTrigger_job_SearchKey] WITH NOCHECK ADD  CONSTRAINT [PK_HBTrigger_job_SearchKey] PRIMARY KEY  NONCLUSTERED ( [Serial] )

SET IDENTITY_INSERT [HBTrigger_job_SearchKey] ON

2、在job_SearchKey 创建修改 删除 触发器

修改触发器:

create Trigger [dbo].[HBTrigger_job_SearchKey_Update]
    On [dbo].[job_SearchKey]                        
    for Update                         

    As                                       
    DECLARE @updateFields nvarchar(4000)
    set @updateFields = ''

    if Update(keyid)          
    begin
    set @updateFields = @updateFields + 'keyid,'
    end       

    if Update(keyword)          
    begin
    set @updateFields = @updateFields + 'keyword,'
    end       

    if Update([Count])          
    begin
    set @updateFields = @updateFields + 'Count,'
    end       

    if Update(type)          
    begin
    set @updateFields = @updateFields + 'type,'
    end       

    if Update(addTime)          
    begin
    set @updateFields = @updateFields + 'addTime,'
    end   
     if Update(upTime)          
    begin
    set @updateFields = @updateFields + 'upTime,'
    end   
     if Update(RecordCount)          
    begin
    set @updateFields = @updateFields + 'RecordCount,'
    end   

    if @updateFields <> ''
    begin
    insert into HBTrigger_job_SearchKey select keyid, 'Update',  @updateFields from Inserted
end

删除触发器

create Trigger [dbo].[HBTrigger_job_SearchKey_Delete]
 
On [dbo].[job_SearchKey]
 
for Delete
 
As
 
insert into HBTrigger_job_SearchKey select keyid, 'Delete', '' from Deleted

注:插入操作不用添加触发器hubbledotnet会自动处理

3、打开hubbledotnet(Query Analyzer) 在job_SearchKey右键选择Table InfoàAttributes

         TableSynchronization设置为true,TriggerTableName 添写第一步创建的触发器表名

4、打开hubbledotnet(Query Analyzer)点击Managerment菜单 选择

Task scheduler managerment 点击Add

exec SP_SynchronizeTable 'job_SearchKey', 5000, 2 是hubbledotnet固定

文章地址:http://www.cnblogs.com/eaglet/archive/2011/03/02/1969219.html

原文地址:https://www.cnblogs.com/freexiaoyu/p/2059867.html