We have a few options for resolving this, most aren't good.
1) we can re-configure the partition.
-- This is bad because of blocking and because of the log file size
2) We can keep the August partition and delete the august data.
-- This is bad, again because of the file size.
3) We can keep the August partition and find a different way of getting rid of the data.
-- This has promise.
What I'm going to end up doing is this:
First I am going to do my normal BCP out of the August data.
Next, make an exact schema copy of the tables in question.
Next switch the August partition to the new tables using this code for each table:
USE DatabaseName
Now that the data is in a "_Staging" table I can work with it without causing blocking on the main table.
I do the following to get rid of the August data:
/*************************************************
1) Get row count of Sept data
*************************************************/
SELECT COUNT(*) FROM TableName
/*************************************************
2) Copy Sept Data into a Temp Table
-- Confirm row count
*************************************************/
SELECT * INTO #Table
/*************************************************
3) Truncate Staging Table
4) Copy data from temp back into staging
-- Confirm row count before issuing Commit
*************************************************/
BEGIN TRAN
TRUNCATE TABLE TableName
INSERT INTO dbo.TableName
( ColumA ,
ColumnB,
ColumnC ,
ColumnD
)
SELECT * FROM #TableName
--ROLLBACK
--COMMIT
/*************************************************
2) Drop Temp table
*************************************************/
DROP TABLE #TableName
Now I switch the partition back from the staging table to the live table:
USE
And Bobs your uncle, as a co-worker likes to say.
No comments:
Post a Comment