Home Forums SQL Server 2014 Administration - SQL Server 2014 Problem Converting DATE. Trying to Purge Data Oldest than 30 days from Performance Counter Table where date column is char (24) RE: Problem Converting DATE. Trying to Purge Data Oldest than 30 days from Performance Counter Table where date column is char (24)

  • Hi

    I have created a workaround:

    ...
    if month(getdate()) = '9' 
    delete FROM dbo.CounterData WHERE CounterDateTime like '%-07-%'
    go
    if month(getdate()) = '10'
    delete FROM dbo.CounterData WHERE CounterDateTime like '%-08-%' 
    go
    ...

    Running this statement for example on 1st day of September, will delete all data from july (month 07). It´s not the best way to do it, but it works. Assuming this runs every month, you guarantee that only one month of data will be available

    I put this code (validating 12 months) in a SQL Agent Job running on 1st day of each month.

    For now its what i need

    Thanks a lot for all sugestions

    Regards
    ...
    Daniel