Stored Proc for Trimming table

  • can some one post a sample to trim a table that has more than ,say older than 30 days ?

    Looking for a little sophisitcated way,

    -thanks

  • Trim a table..do you mean truncate?

     

  • Sorry was not clear in my original posting.

    Looking for a way to delete records in a table older than 30 days. Table does have a column with time stamps of when each row was created.

  • This table must also have clustered index on that column.

    No, I mean MUST have.

    Then it will work very nice:

    DELETE FROM dbo.Table

    WHERE DateRecorded < DATEADD(dd, -30, GETDATE())

    _____________
    Code for TallyGenerator

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply