在sql server 中创建一个作业,定时定期执行一个存储过程。

右键新建存储过程。
第一次创建Alter改为Create
USE [xxxxxxxxDB]
GO
/****** Object: StoredProcedure [dbo].[sp_Sys_JwtLogin] Script Date: 2022/10/28 16:45:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[sp_Sys_JwtLogin]
AS
/*
功能:定时Sys_JWT_Login表expires_in字段--1(或设置为过期数据)
参数:
*/
begin
update Sys_JWT_Login set expires_in-=10 where expires_in>0
delete Sys_JWT_Login where expires_in<=0
end
GO
打开sqlserver代理,右键新建作业,这里我已经创建好了.




作业还可以做很多其他的事情,比如定时备份数据。
博客介绍了在SQL Server中创建作业以定时定期执行存储过程的操作。包括右键新建存储过程,首次创建时将Alter改为Create,还可打开SQL Server代理右键新建作业。此外,作业还能用于定时备份数据等。
549

被折叠的 条评论
为什么被折叠?



