[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

Delete Data over 15 months

Hi All,

I'm looking for a query which will delete all the data that is over 15 months old from a table called Tab A. The column which holds the time is called Data Time. The query will be schedule to run at the end of every month and it should delete the data that is over 15 months.

For ex: If the Data Time is 05/11/09, the query should delete all the rows that are over 03/11/08.

Below is the query I'm trying, I would really appreciate if y'all can provide some comments or suggestions.
DELETE FROM [TABLE A]
WHERE DATEADD (MONTH,-15,[DATA TIME])

Open in new window

0
Samoin
Asked:
Samoin
3 Solutions
 
Aneesh RetnakaranDatabase AdministratorCommented:
DELETE FROM [TABLE A]
WHERE [DATA TIME] <  DATEADD (MONTH,-15,GetDATE() )
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
this will be better:
DELETE FROM [TABLE A]
WHERE [DATA TIME] < DATEADD (MONTH,-15, GETDATE() )

Open in new window

0
 
bull_riderCommented:
This would go good
DELETE FROM [TABLE A]
WHERE [DATA TIME] < DATEADD (MONTH,-15, GETDATE() )

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now