Windows 2003 Server SP1
SQL Server SP4
I have a table in one of my databases (tblLogging) that logs all activity in a users session (ie what button someone clicked, what data they entered/changed, what forms were opened/closed etc.) and as you can imagine the table is enormous. Now that the table has become so big it is slowing down the application. I have been given the task of creating a procedure that will truncate the table and leave only the last two days worth of data in tact. My plan is to query the table for the last two days worth of data, move it to a temp table, truncate the tblLogging table, and then move the data from the temp table back to the tblLogging table. Even though there is going to be only two days worth of data there are still thousands and thousands of rows so I was wondering two things:
1) Does this sound like a good plan or is there a better way to go about it
2) If it sounds ok, what steps should I take to minimize the transaction log activity?? Meaning would it be better to drop the table and then use
Thanks for any help you can give.
SQL Server SP4
I have a table in one of my databases (tblLogging) that logs all activity in a users session (ie what button someone clicked, what data they entered/changed, what forms were opened/closed etc.) and as you can imagine the table is enormous. Now that the table has become so big it is slowing down the application. I have been given the task of creating a procedure that will truncate the table and leave only the last two days worth of data in tact. My plan is to query the table for the last two days worth of data, move it to a temp table, truncate the tblLogging table, and then move the data from the temp table back to the tblLogging table. Even though there is going to be only two days worth of data there are still thousands and thousands of rows so I was wondering two things:
1) Does this sound like a good plan or is there a better way to go about it
2) If it sounds ok, what steps should I take to minimize the transaction log activity?? Meaning would it be better to drop the table and then use
Code:
SELECT field1, field2, field3
INTO tblLogging
FROM #tmpTable
OR
INSERT INTO tblLogging
SELECT field1, field2, field3
FROM #tmpTable
Thanks for any help you can give.