create procedure sps_no_use_user @mnt int
as
--本过程用户得到金蝶K/3系统的当前在用用户情况
--@mnt表示只列出闲置时间超过此分钟数的在用户用户。
select top 100 fuserid,left(ffunctionid,3) as fid,max(fdate) as rq,max(flogid) as lid into #l from t_log
where fdate>=convert(varchar(8),getdate(),112) and ffunctionid like 'K0%' group by fuserid,left(ffunctionid,3) having getdate()-max(fdate)>1.0/24/60*@mnt
--去掉是退出事件的:
delete #l
from #l l,t_log lg where lg.flogid=l.lid and lg.ffunctionid like 'K0_999'
--列出清单:
select u.fname as 用户名,u.fdescription as 用户说明,f.ffunctionname 最后使用功能,cast(getdate()-l.fdate as money)*24.0*60 as 闲置分钟数,
FDATE AS 最后操作时间,fmachinename as 最后操作用电脑,fipaddress as 最后操作IP地址
from t_log l,t_user u,t_logfunction f,#l ll
where f.ffunctionid=*l.ffunctionid and u.fuserid=l.fuserid and ll.lid=l.flogid order by l.ffunctionid,u.fname