how rows get deleted auomatically in sql table after specific interval of time

hi there

i am using .net framework 1.1 with SQL 2000 .

i want the data in table to get deleted automatically after 30 days of inserting data.

so how do i achieve this?

0
vrush25
5/17/2008 6:18:32 AM
asp.net.free-for-all 9281 articles. 0 followers. Follow

4 Replies
368 Views

Similar Articles

[PageSpeed] 25

 This can be achieved by creating Window Service..

check out for tutorial/help/code > Creating a Windows Service in C#

sample window service to send email on a specific date (with DB interaction) >  Birthday Wish Scheduler in C#

for window service deployment help > Windows Services in Action I

after creating window service you can simply create setup and deployment project to create setup.exe file to be installed at the server side.

let me know if you need further assistance..

hope it helps./. 


Thanx,
[KaushaL] || BloG || Profile || Microsoft MVP

"I would love to change the world, but they won’t give me the source code"


Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and mark your thread as Resolved for the sake of Future Readers.
0
kaushalparik27
5/17/2008 6:33:29 AM

thanks for ur reply

i appreciate ur suggestion,but cant this be done without use of windows service .something in the web application itself?

0
vrush25
5/17/2008 6:37:21 AM

when there is no business logic involved, rather than using web application or windows services it's better to schedule a job in sql server itself.

 

HTH 

 

 

 

------------------------------------------------------------------------------------------------
Don't forget to click "Mark as Answer" on the post that helped you. 

0
vinesh
5/17/2008 10:04:42 AM

It depends on how much flexibility/control you have on the database server

DELETE FROM <DBNAME>.<SCHEMANAME>.<TABLENAME>
WHERE DATEDIFF(day,<DATETIMECOLUMNNAME>,GETDATE()) >= 30

You can schedule a job to execute the above t-sql statement once per day every morning [OR] you can execute this as a startup script in your web-application (or whichever the app may be) tied to an even such as first login or session startup or something similar (not ideal though) In case of latter, you better maintain a flag somewhere to check if the statement is ever executed (successfully) for that day.

Regards

Vasu

 

 

 

 


Regards, Sreenivas (Vasu) Chaparala
ps:Unless a question, this is an attempt to provide guidance. Turning this into a solution, if required, is ones own responsibility. Expecting the entire solution as-is is inappropriate for any professional.
0
vasuvani
5/18/2008 12:15:42 AM
Reply: