ALTER INDEX IX_test_CreatedOn ON dbo.test REORGANIZEIt will block the following:
UPDATE STATISTICS dbo.test IX_test_CreatedOnThen it will block the other statement for a long period of time(during the re-indexing):
select top 1 * from test
ALTER INDEX IX_test_CreatedOn ON dbo.test REORGANIZEIt will block the following:
UPDATE STATISTICS dbo.test IX_test_CreatedOnThen it will block the other statement for a long period of time(during the re-indexing):
select top 1 * from test
DECLARE @date DATETIME
SELECT @date = GETDATE()
DECLARE @partValue VARCHAR(10)
DECLARE @priorMonth VARCHAR(10)
SELECT @priorMonth = CONVERT(VARCHAR(25), DATEADD(mm, -7, DATEADD(dd, -(DAY(@date)) + 1 , @date)), 101)
SELECT @partValue = CONVERT(VARCHAR(25), DATEADD(mm, -6, DATEADD(dd, -(DAY(@date)) + 1 , @date)), 101)--using script to move data from fast disk to test_staging slow disk, not include in this script
DECLARE @partNum int
SELECT @partNum = $partition.testPF(@partValue)
DECLARE @priorPartNum int
SELECT @priorPartNum = $partition.testPF(@priorMonth)--switch out data to temp table
ALTER TABLE dbo.test SWITCH PARTITION @partNum TO dbo.test_temp --fast disk
ALTER TABLE dbo.test SWITCH PARTITION @priorPartNum TO dbo.test_staging2 -- on slow disk
ALTER PARTITION FUNCTION [testPF] ()MERGE RANGE (@partValue)--Split the partition by creating a new partition in slow disk file group
ALTER PARTITION SCHEME testPSNEXT USED slowFG
ALTER PARTITION FUNCTION [testPF] ()
ALTERTABLE dbo.test_staging SWITCH TO dbo.test PARTITION @partNum --on slow disk, this is the actual partition need to be moved from fast to slow disk
ALTER TABLE dbo.test_staging2 SWITCH TO dbo.test PARTITION @priorPartNum --on slow disk, this is just to fast split