Results 1 to 2 of 2

Thread: How to archiv part of the table information based on the timestamp?

  1. #1
    Join Date
    Jul 2003
    Posts
    7

    Question How to archiv part of the table information based on the timestamp?

    In my database I want to archive some rows based on the time stamp. I read that horizontal partitioning will do that. This partitioning will insert the rows from the table into some other Database - Tablename. In retrivng those rows back I need to issue separate queries and UNION the result set. Is this way is correct or there any better ways to do this? If it is I have another question. If I add a new column to the table I partitioned, what will happen to the table that I stored in other Database. Is that going to add this new column too?

    If possible please give me a sample code or queries to partition the database.

    Thank you.

  2. #2
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    we run a archive job daily (we keep only 1 year data). the statement looks something like below

    insert into archive_table select * from source_table where convert(varchar(12),timestampval,112) <= convert(varchar(12),(getdate()-365),112)
    delete from source_table where convert(timestampval <= convert(varchar(12),(getdate()-365),112)


    If we add a column in source_table, we also add a column in the archive_table.
    Last edited by MAK; 07-25-2003 at 02:28 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •