home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
moodle.waes.ac.uk
/
moodle.waes.ac.uk.zip
/
moodle.waes.ac.uk
/
TMG
/
SP1-TMG-KB981324-AMD64-ENU.msp
/
PCW_CAB_SHFx2
/
F2143_msfpcui.dll
/
BINARY
/
25434
< prev
next >
Wrap
Text File
|
2010-06-15
|
2KB
|
61 lines
CREATE PROCEDURE [dbo].[ISA_spTopUserAuthFailuresRDL]
@FromDate datetime,
@ToDate datetime,
@ReportType varchar(10),
@TopCount int
AS
BEGIN
DECLARE @SummTableName varchar(100)
SET @SummTableName = dbo.fnGetSummaryTableName('tblUserSummary', @FromDate, @ToDate, @ReportType)
CREATE TABLE #Table1
(
UserName nvarchar(514),
AuthorizedFailures bigint,
)
IF OBJECT_ID (@SummTableName, 'u') IS NOT NULL
BEGIN
DECLARE @strQuery varchar(8000)
SET @strQuery =
'SELECT
[UserName],
SUM([AuthorizedFailures])
FROM ' + @SummTableName + '
WHERE ([date] >= ' + QUOTENAME(CONVERT(varchar, @FromDate, 126),CHAR(39)) + ' AND [date] <= ' + QUOTENAME(CONVERT(varchar, @ToDate, 126),CHAR(39)) + ')
AND ([AuthorizedFailures] <> 0)
GROUP BY [UserName]
ORDER BY SUM([AuthorizedFailures]) DESC
'
INSERT #Table1
EXEC(@strQuery)
END
CREATE TABLE #Table2
(
UserName nvarchar(514),
AuthorizedFailures bigint,
)
INSERT INTO #Table2
SELECT TOP(@TopCount)
[UserName],
[AuthorizedFailures]
FROM #Table1
WHERE [UserName] != N'{[23124]}'
INSERT INTO #Table2
SELECT
N'{[23124]}' As UserName,
SUM(AuthorizedFailures)
FROM #Table1 t1
WHERE NOT EXISTS
(SELECT * FROM #Table2 t2
WHERE t1.UserName = t2.UserName)
DECLARE @TotalFailures bigint
SET @TotalFailures = (SELECT SUM(AuthorizedFailures) FROM #Table2)
SELECT
[dbo].[fnUserOrIpAddressToText]([UserName]) AS [UserName],
[AuthorizedFailures] AS AuthorizedFailures,
CASE
WHEN @TotalFailures = 0 THEN 0
ELSE (CAST(AuthorizedFailures AS decimal) / @TotalFailures)
END As AuthFailureRatio
FROM #Table2
END