CREATE TABLE [hel] (
[a] [int] NULL ,
[b] [int] NULL
) ON [PRIMARY]
GO
create trigger tri_hel_upd
on hel
for update
as
begin
update hel set a=deleted.a+1 from deleted where deleted.b=hel.b and deleted.a=hel.a
end
go
insert into hel select 1,4
insert into hel select 2,6
[a] [int] NULL ,
[b] [int] NULL
) ON [PRIMARY]
GO
create trigger tri_hel_upd
on hel
for update
as
begin
update hel set a=deleted.a+1 from deleted where deleted.b=hel.b and deleted.a=hel.a
end
go
insert into hel select 1,4
insert into hel select 2,6
触发器的话如果当天没有对表的操作,不会引起触发器触发,也就无法实现你的要求
你的数据库服务器-》企业管理器-》管理-》SQL Server 代理-》作业-》新建作业,按照要求填就可以了,在“步骤”的“命令”中填写你要执行的存储过程或语句,在“调度”里面填写什么时间执行
EXEC sp_add_job @job_name = '作业名字'
EXEC sp_add_jobstep @job_name = '作业名字',
@step_name = '步骤名子',
@subsystem = 'TSQL',
@command = 'update 表 set 字段 = 字段+1',
@retry_attempts = 5, --重试次数
@retry_interval = 5 --重试间隔EXEC sp_add_jobschedule @job_name = '作业名字',
@name = '作业调度名字',
@freq_type = 4, -- 每天
@freq_interval = 26, --间隔
@active_start_time = 10000 --开始时间