定时注销电子签核用户

USE [EFNETSYS]
GO
/****** Object:  StoredProcedure [dbo].[SP_Dz]    Script Date: 05/26/2018 16:14:10 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[SP_Dz]
(
    @注销时间 int = 360
) 
AS
BEGIN
    SET NOCOUNT ON;      
--------------------------------------------------------------
if object_id('tempdb..#TempA') is not null drop table #TempA; 
--------------------------------------------------------------
 DECLARE @Time nchar(20) = replace(Convert(nchar(20),GETDATE(),120),'-','/')
 DECLARE @Run_Time_ss int , @XUHAO  varchar(8)
 set @Run_Time_ss =   Convert(int,substring(@Time,18,2))
                    + Convert(int,substring(@Time,15,2)) * 60
                    + Convert(int,substring(@Time,12,2)) * 360 
select * into #TempA from 
(
select 
   ROW_NUMBER() OVER (ORDER BY @XUHAO  ASC) AS '序号'
   ,* 
from 
(
select 
    ZZ001 as 登录者
    ,ZY002 as 起始时间
    ,@Time as 当前时间
    ,@Run_Time_ss - 
        ( Convert(int,substring(ZY002,18,2))
        + Convert(int,substring(ZY002,15,2)) * 60
        + Convert(int,substring(ZY002,12,2)) * 360) as 运行时间
    ,ZZ004 from EFNETSYS.dbo.CRMZZ
left join EFNETSYS.dbo.CRMZY
on ZZ001 = ZY001 and ZZ004 = ZY004 ) as A
where 运行时间 > @注销时间
) as B
---------------------------------------------------------------
DECLARE  @i int = 1
        ,@rows int = (select COUNT(*) from #TempA)
        ,@ZZ004 nchar(20)
if @rows <> 0
begin
    while @i <= @rows
    begin
        select @ZZ004 = ZZ004 from #TempA where 序号 = @i
        delete from EFNETSYS..CRMZZ where ZZ004 = @ZZ004
        set @i = @i + 1
    end
end
drop table #TempA
---------------------------------------------------------------
End

GO

标题名称:定时注销电子签核用户
本文地址:http://bzwzjz.com/article/pgsjde.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 成都网站设计 app网站建设 成都定制网站建设 定制网站设计 盐亭网站设计 成都网站建设 手机网站设计 网站制作报价 上市集团网站建设 手机网站制作 专业网站设计 网站制作公司 成都网站设计 成都网站制作 成都网站建设 成都营销网站建设 成都网站设计 定制网站设计 成都网站制作 成都商城网站制作 高端网站设计 教育网站设计方案