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 / 25208 < prev    next >
Text File  |  2010-06-15  |  1KB  |  34 lines

  1. CREATE PROCEDURE [dbo].[ISA_spSoftBlockSummaryMonthly] 
  2.     @CurrentMonthFirstDay datetime,
  3.     @CurrentMonthLastDay datetime,
  4.     @LastDailyToKeep datetime,
  5.     @LastMonthlyToKeep datetime
  6. AS
  7. BEGIN
  8.     SET NOCOUNT ON;
  9.  
  10.     -- move dailies to monthlies
  11.     INSERT INTO dbo.tblSoftBlockSummary_Monthly
  12.     SELECT 
  13.             [Site] AS [Site],
  14.             [URLCategoryId] AS [URLCategoryId],
  15.             [UserName] AS [UserName],
  16.             SUM([Requests]) AS [Requests],
  17.             @CurrentMonthFirstDay AS [Date]
  18.     FROM dbo.tblSoftBlockSummary_Daily
  19.     WHERE (Date >= @CurrentMonthFirstDay) AND
  20.           (Date <= @CurrentMonthLastDay)
  21.     GROUP BY
  22.             [Site],
  23.             [URLCategoryId],
  24.             [UserName]
  25.             
  26.     -- cleanup dailies
  27.     DELETE FROM [ISA_RS_Db].[dbo].[tblSoftBlockSummary_Daily]
  28.     WHERE (Date < @LastDailyToKeep)
  29.  
  30.     -- cleanup monthlies
  31.     DELETE FROM [ISA_RS_Db].[dbo].[tblSoftBlockSummary_Monthly]
  32.     WHERE (Date < @LastMonthlyToKeep)
  33. END
  34.