Last post Apr 11, 2010 02:36 PM by asprabahar
Apr 11, 2010 10:12 AM|TajKhan|LINK
In my application i want add record in database with the date. My need is that particular record should be deleted on a given date.
Example: i have added one record on 1 Apr 2010 and it will be deleted on 25 Apr 2010.
Any idea how to achieve this? I need a logic to delete that particular record automatically from the database on a given date. I am using MS SQL 2005.
Apr 11, 2010 10:35 AM|Das.Sandeep|LINK
You can acheive this by window service.
Apr 11, 2010 10:37 AM|Das.Sandeep|LINK
One more thing you can do this on insert of any record keep trigger for delete record after five days or you may like. In this case youd don't require any service.
Apr 11, 2010 10:49 AM|ThatsIT|LINK
I would not delete it, instad just mark it with the date, then when you query it, you can use that date to decide if a record is valid. delete by any scedule is not rereliable as the server may be offline and it may not run.
Apr 11, 2010 11:47 AM|TajKhan|LINK
can you send me any example how to achive this?
Apr 11, 2010 02:26 PM|ThatsIT|LINK
what i'm saying is rather then delting the records, just create a fild with an expired date.
then when you select from the table, just select records that have not expired
Apr 11, 2010 02:36 PM|asprabahar|LINK
Create a Job and Deleted the Record ,
Once you create a job u can write a query based on your needs
goto sql agent in the SQL Server and in the Job menu create a new job , in that select the type as TSQL and write u r query