MikeJ-437562
SSC Veteran
Points: 248
More actions
May 7, 2007 at 4:05 pm
#116790
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
Jus
SSCrazy
Points: 2536
May 7, 2007 at 4:06 pm
#704787
Trim a table..do you mean truncate?
May 7, 2007 at 5:32 pm
#704797
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.
Sergiy
SSC Guru
Points: 110209
May 7, 2007 at 5:40 pm
#704800
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 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply