Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Query

Author  Topic 

zxcjggu708
Starting Member

1 Post

Posted - 2013-08-01 : 03:18:16
Hi,
Can any help me, Here I want to delete the old records based on only year, not on entire date,
for example:
DELETE FROM Testpurging TAI WHERE TAI.RECORD_DATE in ( select TAI1.RECORD_DATE from Testpurging TAI1 group by TAI1.RECORD_DATE having MAX(RECORD_DATE) =(SELECT add_months(sysdate, -12 *2) FROM dual));

if i enter 2 then 2 years old records should be deleted etc.

Thank you very much in advance.
Jaggu

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-08-01 : 03:21:26
Seems like you're using in MySQL. This is MS SQL Server forum. You may be better off posting this in some MySQL forums like www.dbforums.com as there're not many MySQL experts here

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -