1
ALTER PROCEDURE dbo.aspnet_Profile_DeleteInactiveProfiles
2
@ApplicationName NVARCHAR(256),
3
@ProfileAuthOptions INT,
4
@InactiveSinceDate DATETIME,
5
@TimeZoneAdjustment INT
6
AS
7
BEGIN
8
DECLARE @ApplicationId UNIQUEIDENTIFIER
9
SELECT @ApplicationId = NULL
10
SELECT @ApplicationId = ApplicationId FROM aspnet_Applications WHERE LOWER(@ApplicationName) = LoweredApplicationName
11
---查询应用程序ID
12
IF (@ApplicationId IS NULL)
13
BEGIN
14
SELECT 0
15
RETURN
16
END
17![](/Images/OutliningIndicators/None.gif)
18
IF (@InactiveSinceDate > CONVERT(DATETIME, '17540101', 112) AND @InactiveSinceDate < CONVERT(DATETIME, '99980101', 112))
19
--如果停滞以来的时间在系统时间内(目前是不会超过条件的时间的)
20
SELECT @InactiveSinceDate = DATEADD(n, -@TimeZoneAdjustment, @InactiveSinceDate)
21
22
DELETE
23
FROM dbo.aspnet_Profile
24
WHERE UserId IN
25
( SELECT UserId
26
FROM dbo.aspnet_Users u
27
WHERE ApplicationId = @ApplicationId
28
AND (LastActivityDate <= @InactiveSinceDate)
29
AND (
30
(@ProfileAuthOptions = 2)
31
OR (@ProfileAuthOptions = 0 AND IsAnonymous = 1)
32
OR (@ProfileAuthOptions = 1 AND IsAnonymous = 0)
33
)
34
)
35
---删除USERID在这一范围内的记录
36
SELECT @@ROWCOUNT
37
END
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/None.gif)
4
![](/Images/OutliningIndicators/None.gif)
5
![](/Images/OutliningIndicators/None.gif)
6
![](/Images/OutliningIndicators/None.gif)
7
![](/Images/OutliningIndicators/None.gif)
8
![](/Images/OutliningIndicators/None.gif)
9
![](/Images/OutliningIndicators/None.gif)
10
![](/Images/OutliningIndicators/None.gif)
11
![](/Images/OutliningIndicators/None.gif)
12
![](/Images/OutliningIndicators/None.gif)
13
![](/Images/OutliningIndicators/None.gif)
14
![](/Images/OutliningIndicators/None.gif)
15
![](/Images/OutliningIndicators/None.gif)
16
![](/Images/OutliningIndicators/None.gif)
17
![](/Images/OutliningIndicators/None.gif)
18
![](/Images/OutliningIndicators/None.gif)
19
![](/Images/OutliningIndicators/None.gif)
20
![](/Images/OutliningIndicators/None.gif)
21
![](/Images/OutliningIndicators/None.gif)
22
![](/Images/OutliningIndicators/None.gif)
23
![](/Images/OutliningIndicators/None.gif)
24
![](/Images/OutliningIndicators/None.gif)
25
![](/Images/OutliningIndicators/None.gif)
26
![](/Images/OutliningIndicators/None.gif)
27
![](/Images/OutliningIndicators/None.gif)
28
![](/Images/OutliningIndicators/None.gif)
29
![](/Images/OutliningIndicators/None.gif)
30
![](/Images/OutliningIndicators/None.gif)
31
![](/Images/OutliningIndicators/None.gif)
32
![](/Images/OutliningIndicators/None.gif)
33
![](/Images/OutliningIndicators/None.gif)
34
![](/Images/OutliningIndicators/None.gif)
35
![](/Images/OutliningIndicators/None.gif)
36
![](/Images/OutliningIndicators/None.gif)
37
![](/Images/OutliningIndicators/None.gif)