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)

  • Lynn Pettis - Thursday, August 9, 2018 9:33 AM

    dfd.francisco 53179 - Thursday, August 9, 2018 9:16 AM

    Hi John Thank you

    Now something is missing me.

    When i run this:

    delete from [dbo].[CounterData]
    where counterdatetime IN
    (
    SELECT counterdatetime
    FROM CounterData
    WHERE TRY_CONVERT(datetime,counterdatetime) IS NULL)


    It delete´s all data from the table.

    Now, how can i keep data from today and delete previous days data (purge)?

    If someone can help me, i appreciate so much

    ...
    Daniel

    You do realize that John just wanted you to run the following, right?

    SELECT counterdatetime
    FROM CounterData
    WHERE TRY_CONVERT(datetime,counterdatetime) IS NULL

    Hi Lynn

    Yes 🙂 no problem, because i am testing this solution for now 🙂