Tuesday, March 27, 2012
Can't be rocket science to delete data older than 30 days?
is it this simple? Or is it supposed to > ?
DELETE FROM LOGRECS
WHERE datediff(d,getdate(), time)<=30Try:
DELETE FROM tbl
WHERE time_col <= DATEADD( d, -30, CURRENT_TIMESTAMP ) ;
Anith|||You're saying within the last 30 days. This statement might be more logical
to follow:
DELETE LogRecs
WHERE [time] < GETDATE() - 30;
or
DELETE LogRecs
WHERE [time] < DATEADD(DAY, -30, GETDATE());
"Kevini" <Kevini@.discussions.microsoft.com> wrote in message
news:5882D56F-7395-46A4-A49E-D0B096A47D8F@.microsoft.com...
> Can it ?
> is it this simple? Or is it supposed to > ?
> DELETE FROM LOGRECS
> WHERE datediff(d,getdate(), time)<=30|||Anith Sen wrote:
> Try:
> DELETE FROM tbl
> WHERE time_col <= DATEADD( d, -30, CURRENT_TIMESTAMP ) ;
> --
> Anith
When in doubt, don't delete.
SELECT MAX(time_col)
-- DELETE
FROM tbl
WHERE time_col <= DATEADD( d, -30, CURRENT_TIMESTAMP ) ;
Measure twice, cut once.|||I only want the last 30 days so nothing earlier than May 29 or should I say
records form today and back 30 days
"Aaron Bertrand [SQL Server MVP]" wrote:
> You're saying within the last 30 days. This statement might be more logic
al
> to follow:
> DELETE LogRecs
> WHERE [time] < GETDATE() - 30;
> or
> DELETE LogRecs
> WHERE [time] < DATEADD(DAY, -30, GETDATE());
>
>
> "Kevini" <Kevini@.discussions.microsoft.com> wrote in message
> news:5882D56F-7395-46A4-A49E-D0B096A47D8F@.microsoft.com...
>
>|||Kevini wrote:
> Can it ?
> is it this simple? Or is it supposed to > ?
> DELETE FROM LOGRECS
> WHERE datediff(d,getdate(), time)<=30
It helps to have the rocket pointed in the right direction... :-)
WHERE DATEDIFF(d, time, GETDATE()) > 30|||Thanks Guys...Aaron's worked beautifully. And the rocket pointed the right
way:-)
"Tracy McKibben" wrote:
> Kevini wrote:
> It helps to have the rocket pointed in the right direction... :-)
> WHERE DATEDIFF(d, time, GETDATE()) > 30
>|||Kevini wrote:
> Thanks Guys...Aaron's worked beautifully. And the rocket pointed the right
> way:-)
>
Houston, we have lift-off!|||>I only want the last 30 days
But your subject says "data older than 30 days"
If you want rows that are within the last 30 days, then
WHERE [time] > DATEADD(DAY, -30, GETDATE())
AND [time] <= GETDATE()|||Kevini wrote:
> Thanks Guys...Aaron's worked beautifully. And the rocket pointed the right
> way:-)
>
So, is it really a rocket, or are you just happy to see us ;)
/impslayer, aka Birger Johansson
Saturday, February 25, 2012
Cannot specify 'dimension' for: Maintenance plan remove files older than
OS: Windows Server 2003 Standard Edition. MSDE 2000.
SQL Server Enterprise Manager Version 8.0.
The Maintenance Plan Wizard will not allow me to specify a value for the 'Remove Files...' I can enter a number but there is nothing in the drop down e.g. 3 'DAYS' perhaps?
Create then plan and then edit - yields the same result.
Any ideas on why there is no 'dimension' for Remove Files Older than ?
Appreciate any tips, ideas, etc.
Thank.s
Anybody have issues trying to specify a dimension for 'Remove Files...' either during Maintenance Wizard (create) or afterwards - edit properties?
The drop down - where you would expect a list of values like: day, week, month - is completely blank?
|||I'm experiencing the exact same problem with my MSDE database. I cannot specify anything as to days, weeks, etc. It also will take other information, such as scheduling, directory, extension name, and actually create the jobs correctly, but then when you go back to the Maintenance Plan, you find the information has disappeared. If you try to modify any other aspect of the plan, you get an error, because this information is now missing. This is the only MSDE db I have, all the rest are standard or enterprise and work normally from the same Enterprise Manager.
I have not found any explanation or work-around for this problem.
Cannot specify 'dimension' for: Maintenance plan remove files older than
OS: Windows Server 2003 Standard Edition. MSDE 2000.
SQL Server Enterprise Manager Version 8.0.
The Maintenance Plan Wizard will not allow me to specify a value for the 'Remove Files...' I can enter a number but there is nothing in the drop down e.g. 3 'DAYS' perhaps?
Create then plan and then edit - yields the same result.
Any ideas on why there is no 'dimension' for Remove Files Older than ?
Appreciate any tips, ideas, etc.
Thank.s
Anybody have issues trying to specify a dimension for 'Remove Files...' either during Maintenance Wizard (create) or afterwards - edit properties?
The drop down - where you would expect a list of values like: day, week, month - is completely blank?
|||I'm experiencing the exact same problem with my MSDE database. I cannot specify anything as to days, weeks, etc. It also will take other information, such as scheduling, directory, extension name, and actually create the jobs correctly, but then when you go back to the Maintenance Plan, you find the information has disappeared. If you try to modify any other aspect of the plan, you get an error, because this information is now missing. This is the only MSDE db I have, all the rest are standard or enterprise and work normally from the same Enterprise Manager.
I have not found any explanation or work-around for this problem.