locked
Date Time Problem RRS feed

  • Question

  • User2080859728 posted

    Hello All

    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.

    Thanks


    Sunday, April 11, 2010 10:12 AM

Answers

  • User-725075801 posted

    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 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, April 11, 2010 2:26 PM

All replies

  • User-1636183269 posted

    You can acheive this by window service. 

    Sunday, April 11, 2010 10:35 AM
  • User-1636183269 posted

    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. 

    Sunday, April 11, 2010 10:37 AM
  • User-725075801 posted

    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.

     

    Sunday, April 11, 2010 10:49 AM
  • User2080859728 posted

    can you send me any example how to achive this?


    Sunday, April 11, 2010 11:47 AM
  • User-725075801 posted

    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 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, April 11, 2010 2:26 PM
  • User-1844410684 posted

    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

    Sunday, April 11, 2010 2:36 PM