locked
Delete rows which are older than 365 days RRS feed

  • Question

  • I know its possible to delete rows in SQL table with date column, but will it be possible to delete rows older than 365 days where you don't have any column specifying date/time?
    Thursday, December 12, 2019 5:01 PM

All replies

  • By default, SQL does not track when the rows are added, modified.

    Obviously you can write logic or use certain features like temporal tables\CDC etc to get when rows are added.

    compare with year old backup or something like that..


    Hope it Helps!!

    Thursday, December 12, 2019 7:03 PM
  • Hi Nick7862,

    Welcome to SQL Server > Transact-SQL.

    I agree with Stan210's advice . If you have no date column , it might be impossible to delete  rows older than 365 days. If you would not like to create a date column in your table . I will suggest you to create a trigger or a history table to store some information about date . So that you may do some operation . 

    Best Regards,

    Rachel 


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, December 13, 2019 6:20 AM
  • Hi ,

     

    I am writing to follow up this thread with you. Have you solved your issue? If you have solved your issue ,in order to close this thread, please kindly mark helpful replies as answers. By doing so, it will benefit all community members who are having this similar issue.  Your contribution is highly appreciated.

     

    Best Regards,

    Rachel


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, December 17, 2019 8:54 AM
  • Hi,

     

    If you find any post in the thread is helpful, you could kindly mark it as answer. This would benefit the community, and also encourage the community member to keep working on your issues.

     

    Best Regards,

    Rachel


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, January 1, 2020 6:47 AM
  • Please take the time to read a classic paper by Dr. Codd the 12 characteristics of relational database. One of these rules is called "the information principle"; it states that all relationships and information in RDBMS are modeled as scalar values in the columns of rows of tables. This is usually covered the first week of any good class on RDBMS; and by the second week in any really bad class on RDBMS. You're not doing your homework, are you?

    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking in Sets / Trees and Hierarchies in SQL

    Wednesday, January 1, 2020 6:50 PM