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.
| Author |
Topic |
|
kvt.aravind
Starting Member
24 Posts |
Posted - 2010-08-24 : 02:46:22
|
| To delete the records older than 90 days once in a month automatically... How to do it Kindly helpdelete from [TATA_TRAVEL_EXPENSEINFONEW] WHERE [TATA_TRAVEL_EXPENSEINFONEW].EXP_DATE < dateadd(dd,-90,getdate()) AND [TATA_TRAVEL_EXPENSEINFONEW].STATUS IN ('Open')godelete from [TATA_TRAVEL_EXPENSEINFONEW] WHERE [TATA_TRAVEL_EXPENSEINFONEW].EXP_DATE < dateadd(dd,-90,getdate()) AND [TATA_TRAVEL_EXPENSEINFONEW].STATUS IN ('DELETED')godelete from tata_travel_ticketinfo where status in ('Deleted')goDelete from tata_travel_ticketinfo Where tata_travel_ticketinfo.book_id in (select tata_travel_ticketinfo.book_id from tata_travel_ticketinfo inner join tata_travel_bookticketnew on tata_travel_bookticketnew.book_id = tata_travel_ticketinfo.book_id and tata_travel_ticketinfo.Status in ('open') and tata_travel_ticketinfo.created_on < dateadd(dd,-90,getdate()))gonormally i execute the above query once in a month to delete the records in open status and deleted status from two tables but i need this to be done automaticaly once in a month...kindly suggest...its urgent..RegardsAravind.TAravind.T |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
kvt.aravind
Starting Member
24 Posts |
Posted - 2010-08-24 : 04:38:31
|
| can we schedule the above queries in single stored procedure or query by queryAravind.T |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-08-24 : 05:00:51
|
quote: Originally posted by kvt.aravind can we schedule the above queries in single stored procedure or query by queryAravind.T
It is better to have them in a procedureMadhivananFailing to plan is Planning to fail |
 |
|
|
kvt.aravind
Starting Member
24 Posts |
Posted - 2010-08-24 : 05:25:23
|
| Is It possible to store the records in separate table before they are deleted. I used select * into XXX inside the stored procedure to get the records which are beyond 90 days but i excuted first timeie., first month it executed successfully but second time the next month if i execute it displays invalid object name xxxAravind.T |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
kvt.aravind
Starting Member
24 Posts |
Posted - 2010-08-24 : 06:45:36
|
| Incase the client needs to see the deleted records means...I can get the data from these tables...Partition of table means?Aravind.T |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|
|