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 / 25158 < prev    next >
Text File  |  2010-06-15  |  869b  |  30 lines

  1. CREATE PROCEDURE [dbo].[ISA_spUrlfUserSummaryMonthly]
  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.tblUrlfUserSummary_Monthly
  12.     SELECT
  13.             [UserName] AS UserName,
  14.             SUM([UrlfIncidents]) AS UrlfIncidents,
  15.             @CurrentMonthFirstDay AS Date
  16.     FROM dbo. tblUrlfUserSummary_Daily
  17.     WHERE (Date >= @CurrentMonthFirstDay) AND
  18.           (Date <= @CurrentMonthLastDay)
  19.     GROUP BY
  20.             [UserName]
  21.  
  22. -- cleanup dailies
  23.     DELETE FROM [ISA_RS_Db].[dbo].[tblUrlfUserSummary_Daily]
  24.     WHERE (Date < @LastDailyToKeep)
  25.  
  26. -- cleanup monthlies
  27.     DELETE FROM [ISA_RS_Db].[dbo].[tblUrlfUserSummary_Monthly]
  28.     WHERE (Date < @LastMonthlyToKeep)
  29. END
  30.