ALTER PROCEDURE dbo.aspnet_Profile_GetNumberOfInactiveProfiles
@ApplicationName NVARCHAR(256),
@ProfileAuthOptions INT,
@InactiveSinceDate DATETIME,---自从停止活跃开始的时间
@TimeZoneAdjustment INT
AS
BEGIN
DECLARE @ApplicationId UNIQUEIDENTIFIER
SELECT @ApplicationId = NULL
SELECT @ApplicationId = ApplicationId FROM aspnet_Applications WHERE LOWER(@ApplicationName) = LoweredApplicationName
-----------------------------查询ApplicationId---------------
IF (@ApplicationId IS NULL)
BEGIN
SELECT 0
RETURN
END
IF (@InactiveSinceDate > CONVERT(DATETIME, '17540101', 112) AND @InactiveSinceDate < CONVERT(DATETIME,'99980101', 112))
SELECT @InactiveSinceDate = DATEADD(n, -@TimeZoneAdjustment, @InactiveSinceDate)
----------如果停滞以来的时间在系统时间内(目前是不会超过条件的时间的)-----------------
SELECT COUNT(*)
FROM dbo.aspnet_Users u, dbo.aspnet_Profile p
WHERE ApplicationId = @ApplicationId
AND u.UserId = p.UserId
AND (LastActivityDate <= @InactiveSinceDate)
AND (
(@ProfileAuthOptions = 2)
OR (@ProfileAuthOptions = 0 AND IsAnonymous = 1)
OR (@ProfileAuthOptions = 1 AND IsAnonymous = 0)
)
/*计算符合条件的记录数aspnet_Profile中的 propertyNames 好象是保存用户的
附加信息的,比如生日,QQ,博客地址等.*/
END
@ApplicationName NVARCHAR(256),
@ProfileAuthOptions INT,
@InactiveSinceDate DATETIME,---自从停止活跃开始的时间
@TimeZoneAdjustment INT
AS
BEGIN
DECLARE @ApplicationId UNIQUEIDENTIFIER
SELECT @ApplicationId = NULL
SELECT @ApplicationId = ApplicationId FROM aspnet_Applications WHERE LOWER(@ApplicationName) = LoweredApplicationName
-----------------------------查询ApplicationId---------------
IF (@ApplicationId IS NULL)
BEGIN
SELECT 0
RETURN
END
IF (@InactiveSinceDate > CONVERT(DATETIME, '17540101', 112) AND @InactiveSinceDate < CONVERT(DATETIME,'99980101', 112))
SELECT @InactiveSinceDate = DATEADD(n, -@TimeZoneAdjustment, @InactiveSinceDate)
----------如果停滞以来的时间在系统时间内(目前是不会超过条件的时间的)-----------------
SELECT COUNT(*)
FROM dbo.aspnet_Users u, dbo.aspnet_Profile p
WHERE ApplicationId = @ApplicationId
AND u.UserId = p.UserId
AND (LastActivityDate <= @InactiveSinceDate)
AND (
(@ProfileAuthOptions = 2)
OR (@ProfileAuthOptions = 0 AND IsAnonymous = 1)
OR (@ProfileAuthOptions = 1 AND IsAnonymous = 0)
)
/*计算符合条件的记录数aspnet_Profile中的 propertyNames 好象是保存用户的
附加信息的,比如生日,QQ,博客地址等.*/
END
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步