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
/
25076
< prev
next >
Wrap
Text File
|
2010-06-15
|
3KB
|
75 lines
CREATE PROCEDURE [dbo].[ISA_spProtocolSummaryTrim]
AS
BEGIN
SET NOCOUNT ON;
IF OBJECT_ID ('tblProtocolSummary', 'u') IS NULL
RETURN
DECLARE @FromDate datetime
SET @FromDate = (SELECT [FromDate] FROM [tblSummaryParams])
CREATE TABLE #Table1
(
[ProtocolName] nvarchar(128),
[BytesIn] bigint,
[BytesOut] bigint,
[TotalBytes] bigint,
[Requests] bigint,
[LogType] bit,
[Date] datetime
)
DECLARE @SQLString1 nvarchar(2000) =
'SELECT *
FROM (
SELECT
[ProtocolName], [BytesIn], [BytesOut], [TotalBytes], [Requests], [LogType], [Date]
FROM (
SELECT
[ProtocolName], [BytesIn], [BytesOut], [TotalBytes], [Requests], [LogType], [Date],
ROW_NUMBER() OVER (PARTITION BY [LogType] ORDER BY '
DECLARE @SQLString2 nvarchar(2000) =
' DESC) AS rownum
FROM dbo.[tblProtocolSummary]
WHERE '
DECLARE @SQLString3 nvarchar(2000) =
' > 0) t
WHERE rownum <= 5000
) ttt
WHERE [ProtocolName] IS NOT NULL
AND NOT EXISTS (SELECT * FROM #Table1
WHERE ttt.[ProtocolName] = [ProtocolName] AND
ttt.[LogType] = [LogType])'
DECLARE @SQLString nvarchar(4000)
DECLARE @OrderString nvarchar(200)
SET @OrderString = '[TotalBytes]'
SET @SQLString = @SQLString1 + @OrderString + @SQLString2 + @OrderString + @SQLString3;
PRINT @SQLString
INSERT INTO #Table1
EXECUTE(@SQLString)
SET @OrderString = '[Requests]';
SET @SQLString = @SQLString1 + @OrderString + @SQLString2 + @OrderString + @SQLString3;
INSERT INTO #Table1
EXECUTE(@SQLString)
SET @OrderString = '[BytesIn]';
SET @SQLString = @SQLString1 + @OrderString + @SQLString2 + @OrderString + @SQLString3;
INSERT INTO #Table1
EXECUTE(@SQLString)
SET @OrderString = '[BytesOut]';
SET @SQLString = @SQLString1 + @OrderString + @SQLString2 + @OrderString + @SQLString3;
INSERT INTO #Table1
EXECUTE(@SQLString)
---- now add tail
INSERT INTO #TABLE1
SELECT
N'{[23124]}', SUM([BytesIn]), SUM([BytesOut]), SUM([TotalBytes]), SUM([Requests]), [LogType], @FromDate
FROM dbo.[tblProtocolSummary] ttt
WHERE
NOT EXISTS (SELECT *
FROM #Table1
WHERE ttt.[ProtocolName] = [ProtocolName] AND
ttt.[LogType] = [LogType])
GROUP BY [LogType]
TRUNCATE TABLE [tblProtocolSummary]
INSERT INTO [tblProtocolSummary]
SELECT *
FROM #TABLE1
END