PURGEEVENTLOG

Last post 11-23-2005 12:03 PM by DeveloperMCDBA. 3 replies.

Sort Posts:

  • PURGEEVENTLOG

    11-22-2005, 6:15 AM
    • Member
      550 point Member
    • polash26
    • Member since 07-22-2003, 3:28 AM
    • Posts 113
    Can anybody tell me, how to read PURGEEVENTLOG  store procedure? I mean what is that delete doing?
    Thanks for reply.  
  • Re: PURGEEVENTLOG

    11-22-2005, 11:11 PM
    • Contributor
      5,570 point Contributor
    • DeveloperMCDBA
    • Member since 05-08-2005, 4:08 AM
    • Deltona, FL, USA
    • Posts 1,114
    do you have enterprise manager or query analyzer?



    DELETE FROM dbo.EventLog

    FROM dbo.EventLogConfig elc

    WHERE

    (

    SELECT COUNT(*)

    FROM dbo.EventLog el

    WHERE el.LogConfigID = elc.ID

    and dbo.EventLog.LogTypeKey = el.LogTypeKey

    and el.LogCreateDate >= dbo.EventLog.LogCreateDate

    ) > elc.KeepMostRecent

    AND elc.KeepMostRecent<>-1

     

  • Re: PURGEEVENTLOG

    11-23-2005, 5:06 AM
    • Member
      550 point Member
    • polash26
    • Member since 07-22-2003, 3:28 AM
    • Posts 113
     DeveloperMCDBA wrote:
    do you have enterprise manager or query analyzer?



    DELETE FROM dbo.EventLog

    FROM dbo.EventLogConfig elc

    WHERE

    (

    SELECT COUNT(*)

    FROM dbo.EventLog el

    WHERE el.LogConfigID = elc.ID

    and dbo.EventLog.LogTypeKey = el.LogTypeKey

    and el.LogCreateDate >= dbo.EventLog.LogCreateDate

    ) > elc.KeepMostRecent

    AND elc.KeepMostRecent<>-1



    Sorry, I think, my question wasn't very clear. I have those tools, actually I haven't seen that type of delete statement before. What that delete will do? Does it delete data only from EventLog table? What does that delete from T1 from T2 mean???
  • Re: PURGEEVENTLOG

    11-23-2005, 12:03 PM
    • Contributor
      5,570 point Contributor
    • DeveloperMCDBA
    • Member since 05-08-2005, 4:08 AM
    • Deltona, FL, USA
    • Posts 1,114
    >>only from eventlog table?

    yes, that's what it looks like. Most of that sql is in the where clause, meaning, it is telling it exactly what to delete.

    >>t1 & t2?

    where do you see this? More than likely you're talking about table aliases. Look in this query. You'll see elc as an alias for EventLogConfig. This is created/used so that the whole table name doesn't have to be typed out every time the coder wants to reference the table.
Page 1 of 1 (4 items)