TheBugSlayer
Programmer
The audit tableon a SQL Server 2008 contains more than 400 million records. The table is heavily used and has become a drag on the database. Over the week-end it was renamed and a brand new audit table was created.
Now we need to copy a year’s worth of data back to the live audit table, the one that was recreated. However, there is not one single column that uniquely identifies rows in the audit table. I need to find a way to add a year’s worth of records back to the live audit table while keeping track of the records that have already been added back to avoid duplication. There is about 200 million records to add back, we cannot add them all at once but rather a certain number at a time so as not to tax the database too much.
I am thinking of duplicating the whole archive audit table, the one with the 400 million rows and adding a new Boolean column to it. That column will indicate whether the row has already been added over to the live audit table. The rows to be added back will come from the result set of a query that filters by the transaction date, returning only a year’s worth of data.
If anyone has a different idea, a more efficient one I would like to hear about it. I will be tinkering with my idea in the meantime…
Thank you.
MCP SQL Server 2000, MCTS SQL Server 2005, MCTS SQL Server 2008 (DBD, DBA)
Now we need to copy a year’s worth of data back to the live audit table, the one that was recreated. However, there is not one single column that uniquely identifies rows in the audit table. I need to find a way to add a year’s worth of records back to the live audit table while keeping track of the records that have already been added back to avoid duplication. There is about 200 million records to add back, we cannot add them all at once but rather a certain number at a time so as not to tax the database too much.
I am thinking of duplicating the whole archive audit table, the one with the 400 million rows and adding a new Boolean column to it. That column will indicate whether the row has already been added over to the live audit table. The rows to be added back will come from the result set of a query that filters by the transaction date, returning only a year’s worth of data.
If anyone has a different idea, a more efficient one I would like to hear about it. I will be tinkering with my idea in the meantime…
Thank you.
MCP SQL Server 2000, MCTS SQL Server 2005, MCTS SQL Server 2008 (DBD, DBA)