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