Last post Nov 03, 2016 03:14 PM by bbcompent1
Oct 20, 2016 10:45 AM|bbcompent1|LINK
Good morning everyone, I am trying to figure out how to move certain columns from one table to another. Here is the kicker; each column in this active table has a date format of the letter D with yyyymmdd (for example today would be D20161020). What I am
trying to do is to take all columns from the previous month (for example D201609##) and move them to an archive table (copy then remove the copied columns).
My plan and thinking is to keep the current data lean to be as quick as possible. And yes I am using indexes, I just do not want the table to get that big. :) Each day, I import 3000+ records into that table. For slimness, I am referring by record ID to
the master record table. Essentially, this table has a RecID Foreign Key to the master record table RecID and the date in that format Dyyyymmdd. I place the count for that date into the corresponding records.
Here is the other thing, I am looking to only keep the current month's data in the active table.
I plan to keep the archive tables by year, i.e 2016counts, 2017counts which will hold that year's data.
I figure for the yearly archive table, I can simply create a proc that will copy all the data from the current archive table to the year archive and then truncate that active table. Or rename the table and just re-create a blank table like it since the active archive
table will have nothing in it except for the first column which is a correlated record ID from a master table of records.
It is not a question of whether I can figure this out, I am more looking for advice on how other developers would handle this unique situation. Thanks guys and gals!
Oct 25, 2016 03:18 AM|CoCoxTtt|LINK
I am trying to figure out how to move certain columns from one table to another.
perhaps this article would help.
Oct 27, 2016 05:13 PM|bbcompent1|LINK
I'm just seeing this, I will give this a try in the morning. It may be just what I am looking for. Thanks!
Nov 03, 2016 01:14 PM|bbcompent1|LINK
After doing some additional research, this script appears to be creating a Cartesian product, rather than inserting the rows as they are into the table. I was looking around and instead of having 4000 rows, I ended up with over 50,000, the CVE Ids kept repeating.
I may do this archival process once per year. I am thinking the most simplified way to do this would be create a table that is a snapshot of the entire previous year's data and then remove the records from last year. Let me go digging around to see what I
can figure out. I thought it would be relatively simple but I can admit I was wrong about that.
Nov 03, 2016 03:14 PM|bbcompent1|LINK
Never mind, something went totally ballistic with my data source. The archive script you've presented does work so I'll mark your answer again. Sorry about that.