Solved

Delete Data over 15 months

Posted on 2009-05-11
4
259 Views
Last Modified: 2013-11-30
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
Comment
Question by:Samoin
4 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 150 total points
ID: 24355852
DELETE FROM [TABLE A]
WHERE [DATA TIME] <  DATEADD (MONTH,-15,GetDATE() )
0
 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 50 total points
ID: 24355874
this will be better:
DELETE FROM [TABLE A]
WHERE [DATA TIME] < DATEADD (MONTH,-15, GETDATE() )

Open in new window

0
 
LVL 6

Assisted Solution

by:bull_rider
bull_rider earned 50 total points
ID: 24355901
This would go good
DELETE FROM [TABLE A]

WHERE [DATA TIME] < DATEADD (MONTH,-15, GETDATE() )

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this article—a derivative of my DaytaBase.org blog post (http://daytabase.org/2011/06/18/what-week-is-it/)—I will explore a few different perspectives on which week today's date falls within using Microsoft SQL Server. First, to frame this stu…
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now